Skip to content

Instantly share code, notes, and snippets.

View BBarbosa's full-sized avatar
🎯
Focusing

Bruno Barbosa BBarbosa

🎯
Focusing
  • AI4MedImaging, Medical Solutions
  • Braga, Portugal
View GitHub Profile
@BBarbosa
BBarbosa / auto_execute.py
Last active December 2, 2019 18:00
Auto commands line generator from parameteres dictionary
"""Auto commands line generator from parameteres dictionary.
Example:
>>> params_dict = {
"--model_path": ["model1.hdf5", "model2.hdf5"],
"--debug": True,
"--score": [0.1, 0.2],
"--iou": [0.3, 0.4]
}
@BBarbosa
BBarbosa / timeout.py
Created August 1, 2019 15:01
Similiar implementation of windows timeout command
"""
Python function to simulate Windows timeout command
NOTE: It may not work on Linux due to mvscrt library
"""
from msvcrt import getch, kbhit
from time import sleep
@BBarbosa
BBarbosa / input_parser_function.py
Last active June 26, 2019 16:36
Python custom type arguments parser
def input_parser(obj_type=None, min_value=None, max_value=None, clip=False):
if obj_type in (int, float) and min_value is not None and max_value is not None and min_value > max_value:
raise ValueError("Minimum value (" + str(min_value) + ") is greater than maximum value (" + str(max_value) + ")")
def input_parser_value(value):
if obj_type is not None:
value = obj_type(value)
if obj_type in (int, float):
if min_value is not None and value < min_value: