Oh that makes sense.
So now you can just get the models as dict as well (basically clearml allows you to access them both as a list, so it is easy to get the last created, and as dict so you can match the filenames)
This one will get the list of modelsprint(task.models["output"].keys())
Now you can just pick the best onemodel = task.models["output"]["epoch13-..."] my_model_file = model.get_local_copy()
Hi MistakenDragonfly51
Notice that Models are their own entity, you can query them based on tags/projects/names etc.
Querying and getting Models is done by Model class:
https://clear.ml/docs/latest/docs/references/sdk/model_model#modelquery_models
task.get_models()
is always empty. (edited)
How come there are no Models on the Task? (in other words how come this is empty?)
That's a very good question.
They are visible in the UI.
And accessible in the way I mentioned above.
Any idea?
Well it seems we forgot that one 😞 I'll quickly make sure it is there.
As a quick solution (no need to upgrade)task.models["output"]._models.keys()
Wait, that makes no sense to me. The API from python and the API from the UI are getting the same data from the backend ...
What are you getting with?from clearml import Task task = Task.get_task(task_id=<put task id here>) print(task.models)
sorry, they both return the same. was a typo in my test for task.models
vs task.get_models()
I'm assuming it's in a later version than 1.7.1 (the one I'm running).
But I guess for my question #1 I was doing it fine. Do you have any idea for #2?
Old bug and I should update maybe?
Hi MistakenDragonfly51 , regarding your questions:
ClearML has a model repository built in. You can load an input model using InputModel module ( https://clear.ml/docs/latest/docs/references/sdk/model_inputmodel ). Also, you can fetch the models of an experiment using Task.get_models()
- https://clear.ml/docs/latest/docs/references/sdk/task#get_models Can you elaborate on how this config looks in the UI when you view it?
For now, I retrieve and load the model as follows (pytorch lightning)clearml_model = task.models['output'][-1] model_path = clearml_model.get_local_copy() main_loop = LightningModel.load_from_checkpoint(checkpoint_path=model_path)
Not sure how InputModel
would help and task.get_models()
is always empty.
- in the UI it does have the proper types.