allegroai / clearml

ClearML - Auto-Magical CI/CD to streamline your AI workload. Experiment Management, Data Management, Pipeline, Orchestration, Scheduling & Serving in one MLOps/LLMOps solution
https://clear.ml/docs
Apache License 2.0
5.61k stars 651 forks source link

Cannot use OutputModel.report_confusion_matrix before OutputModel.update_weights #1078

Open HarryGoodman opened 1 year ago

HarryGoodman commented 1 year ago

Describe the bug

I am trying to report a confusion matrix for my Output Model but it seems that if I try and do this before running OutputModel.update_weights it gives a warning and does not throw an error.

To reproduce

`task = Task.init(project_name=params['project name'], task_name= "-".join([params['task name'], params['net']['model'], 'lr', str(params['opt']['lr'])]), auto_connect_frameworks={"tensorflow":False,"tensorboard": False,'pytorch': False,})

output_model = OutputModel(task=task, framework="PyTorch", config_dict = params, tags = [params['project name']] + params['tags'],)

[...]

output_model.report_confusion_matrix(title = "Validation Confusion Matrix", series = "Validation Data", matrix = best_total_cm, xaxis = "Predicted Labels", yaxis = "True Labels", xlabels = list(classes.keys()), ylabels = list(classes.keys()),)

output_model.update_weights( weights_filename=os.path.join(params["output dir"],'model_best.pth'), auto_delete_file=False, ) `

Expected behaviour

I get the following warning: 2023-07-18 14:15:34,407 - clearml.Metrics - ERROR - Action failed <400/131: events.add_batch/v1.0 (Events not added: Event must have a 'task' field=1)> The confusion matrix does not upload to the clearml server. However, when I swap the report_confusion_matrix and update_weights I do not get the warning and the confusion matrix is uploaded.

Environment

Related Discussion

https://clearml.slack.com/archives/CTK20V944/p1689654081105309

AlexandruBurlacu commented 1 year ago

Hey @HarryGoodman, we just released ClearML SDK 1.12.2 which should fix this issue. Can you please try it and tell us whether it works now?