Skip to content

Instantly share code, notes, and snippets.

View thepycoder's full-sized avatar

Victor Sonck thepycoder

View GitHub Profile
# report every 1 minute, this is way too often, but we are testing here
optimizer.set_report_period(1)
# start the optimization process
# this function returns immediately
optimizer.start()
# set the time limit for the optimization process (2 hours)
optimizer.set_time_limit(in_minutes=120.0)
# wait until process is done (notice we are controlling the optimization process in the background)
optimizer.wait()
# optimization is completed, print the top performing experiments id
from clearml.automation import UniformParameterRange, UniformIntegerParameterRange, DiscreteParameterRange
from clearml.automation import HyperParameterOptimizer
from clearml.automation import GridSearch
from clearml import Task
task = Task.init(project_name='HPO Code',
task_name='basic dict optimizer',
task_type=Task.TaskTypes.optimizer,
reuse_last_task_id=False)
logger = task.get_logger()
logger.report_scalar('Optimization Metric', 'model_output', iteration=0, value=model_output)
class Model:
def run():
return example_configuration['epochs'] * 10
model_output = Model().run()
example_configuration = {
'epochs': 3,
'lr': 0.001,
'comments': 'I like apple juice'
}
task.connect(example_configuration)
from clearml import Task
task = Task.init(project_name="HPO Example", task_name="basic dict example")
@thepycoder
thepycoder / dummy_model.py
Created February 28, 2022 13:58
Dummy Model
from clearml import Task
task = Task.init(project_name="HPO Example", task_name="basic dict example")
example_configuration = {
'epochs': 3,
'lr': 0.001,
'comments': 'I like apple juice'
}
task.connect(example_configuration)
def pipe_to_virtual_webcam(self):
with pyvirtualcam.Camera(width=854, height=480, fps=30) as cam:
print(f'Using virtual camera: {cam.device}')
while self.is_running:
frame = self.webcam_queue.get()
cam.send(frame)
cam.sleep_until_next_frame()
def run(self):
pipeline = self.create_pipeline()
# Pipeline defined, now the device is connected to
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()
# Set queues to be read from later
self.high_quality_out = device.getOutputQueue(name="high_quality_out", maxSize=4, blocking=False)
self.detection_out = device.getOutputQueue(name="detection_out", maxSize=4, blocking=False)
def create_pipeline(self):
# Create pipeline and set version
pipeline = dai.Pipeline()
pipeline.setOpenVINOVersion(version=dai.OpenVINO.Version.VERSION_2021_3)
# Camera specific settings
cam = pipeline.createColorCamera()
cam.setPreviewSize(*self.nn_shape)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam.setInterleaved(False)