Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Zoo API #355

Closed
wants to merge 13 commits into from
Closed

Model Zoo API #355

wants to merge 13 commits into from

Conversation

kundanapillari
Copy link
Contributor

@kundanapillari kundanapillari commented Aug 11, 2020

Python-API-Script

Onnx Python API Script used to download and save pretrained models from onnx model zoo. Retrieves metadata after the model is successfully downloaded.

Features

get_model_versions(MODEL_FOLDER_NAME) - Retrieves an array of all the versions of the specificed model folder in the Onnx Model Zoo.

get_pretrained() - Downloads and saves specific onnx models to desired path.

get_metadata() - Retrieves metadata of the onnx model.

Intialization and Usage

Initiate the object by calling onnx_zoo class name.

OBJECT_NAME = onnx_zoo()

The Python scipt will then ask to input the model folder name. When inputting the name, it should be in all lowercase.

Enter Model Name: resnet

After model folder name is inputted, the script will output all the model versions that exist in the folder.

['resnet101-v1-7', 'resnet101-v2-7', 'resnet152-v1-7', 'resnet152-v2-7', 'resnet18-v1-7', 'resnet18-v2-7', 'resnet34-v1-7', 'resnet34-v2-7', 'resnet50-caffe2-v1-3', 'resnet50-caffe2-v1-6', 'resnet50-caffe2-v1-7', 'resnet50-caffe2-v1-8', 'resnet50-caffe2-v1-9', 'resnet50-v1-7', 'resnet50-v2-7']

From the array of versions, input the version that will be downloaded and input the local directory that the model will be saved in.

Enter model name from options: resnet101-v1-7 
Enter saved path: /Users/name/Downloads

To download the model and output its metadata, run the following functions:

OBJECT_NAME.get_pretrained()
OBJECT_NAME.get_metadata()

Installation

Install onnx to check models

pip install onnx

Install onnxruntime to run onnx models

pip install onnxruntime

Contributors


@lgtm-com
Copy link

lgtm-com bot commented Aug 11, 2020

This pull request introduces 9 alerts when merging 9d0b826 into f1cb2cf - view on LGTM.com

new alerts:

  • 5 for Unused import
  • 3 for Except block handles 'BaseException'
  • 1 for Unused argument in a formatting call

@lgtm-com
Copy link

lgtm-com bot commented Aug 11, 2020

This pull request introduces 3 alerts when merging 652225c into f1cb2cf - view on LGTM.com

new alerts:

  • 3 for Except block handles 'BaseException'

@lgtm-com
Copy link

lgtm-com bot commented Aug 11, 2020

This pull request introduces 3 alerts when merging 8c06863 into adef8dd - view on LGTM.com

new alerts:

  • 3 for Except block handles 'BaseException'

@vinitra-zz vinitra-zz requested a review from askhade August 11, 2020 22:30
@lgtm-com
Copy link

lgtm-com bot commented Aug 12, 2020

This pull request introduces 3 alerts when merging dade22a into adef8dd - view on LGTM.com

new alerts:

  • 3 for Except block handles 'BaseException'

@@ -0,0 +1,117 @@
modelDict = {"bertsquad-10" : "https://github.com/onnx/models/blob/master/text/machine_comprehension/bert-squad/model/bertsquad-10.onnx?raw=true" ,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR. It is an awesome work.
One question:
Are these model urls here hard-coded?

If yes, I think maybe these urls can be parsed from onnx/models automatically. (finding those onnx models under model/ directory)
In that case, this API can be automatically updated while new models are introduced to model zoo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used the generate_models.py file to generate the links of the models automatically. It is included in the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kundanapillari - is it necessary to include this dictionary directly? Since we've included the scripts to dynamically generate these files, can they be generated in the initialization step?

The problem is that we'll continually have to keep updating this dictionary of models if we check this in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one issue with having the dictionary be generated in the initialization step is that the user has to have an updated cloned repository for it to be able to traverse through the model zoo and create the dict.

Copy link
Member

@vinitra-zz vinitra-zz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great start!

model-zoo-api/dict/generate_model_versions.py Outdated Show resolved Hide resolved
model-zoo-api/README.md Outdated Show resolved Hide resolved
model-zoo-api/README.md Outdated Show resolved Hide resolved
model-zoo-api/README.md Outdated Show resolved Hide resolved
model-zoo-api/README.md Outdated Show resolved Hide resolved
model-zoo-api/README.md Outdated Show resolved Hide resolved
model-zoo-api/python_api_script.py Outdated Show resolved Hide resolved
model-zoo-api/python_api_script.py Outdated Show resolved Hide resolved
model-zoo-api/python_api_script.py Outdated Show resolved Hide resolved
model-zoo-api/python_api_script.py Show resolved Hide resolved
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kundanapillari
❌ vinitra
You have signed the CLA already but the status is still pending? Let us recheck it.

@prasanthpul
Copy link
Member

Superceded by #455

@prasanthpul prasanthpul closed this Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants