Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question: Model dowloading with custom vision & python API

i am new to Microsoft Custom Vision and I am working on an intergration of Microsoft Azure Custom Vision API using jupyter notebooks/python. I was able to upload images, tag them automatically and train the first iterations. However, as I was trying to download a Docker file of the train iteration/model I got stuck while trying to export the model. Using the function export_iteration I ended up having an mst.rest.pipeline.clientrawresponse object. I think currently it is only stored in the exporting queue. How do I access this queue element to download it to my local system?

PS: I am working with a General (compact) model format so it should be exportable.

Example code:

# Initalize the Training Client 
training_key = "your-training-key"
ENDPOINT = "your-endpoint" 

c_plat = CustomVisionTrainingClient(training_key,ENDPOINT)
# List all projects you have
projects = c_plat.get_projects()

#Always take the newest project and its newest iteration and export it 
iterations = c_plat.get_iterations(projects[0].id)
c_plat.export_iteration(project_id=projects[0].id, iteration_id=iterations[0].id, platform = "DockerFile", raw=True, flavor = "ARM")

like image 888
ruki ami Avatar asked Oct 22 '25 11:10

ruki ami


1 Answers

After some trial and error I found a solution:

    #Always takes the newest project and its newest iteration
    iterations = c_plat.get_iterations(projects[0].id)
    response = c_plat.export_iteration(project_id=projects[0].id, iteration_id=iterations[0].id, platform = "DockerFile", raw=False, flavor="ARM")

    # Opnening the uri
    import webbrowser
    webbrowser.open(c_plat.get_exports(project_id=projects[0].id, iteration_id=iterations[0].id)[0].download_uri)

This opened the uri in a new tab and started the automatic download. Hope this might help somebody else.

Cheers!

like image 100
ruki ami Avatar answered Oct 25 '25 01:10

ruki ami