This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logger = task.get_logger() | |
logger.report_scalar('Optimization Metric', 'model_output', iteration=0, value=model_output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model: | |
def run(): | |
return example_configuration['epochs'] * 10 | |
model_output = Model().run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example_configuration = { | |
'epochs': 3, | |
'lr': 0.001, | |
'comments': 'I like apple juice' | |
} | |
task.connect(example_configuration) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from clearml import Task | |
task = Task.init(project_name="HPO Example", task_name="basic dict example") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |