Skip to content

Refactored download_models.py#1129

Merged
asmorkalov merged 2 commits intoopencv:4.xfrom
mshabunin:model-dl-multi
Dec 11, 2023
Merged

Refactored download_models.py#1129
asmorkalov merged 2 commits intoopencv:4.xfrom
mshabunin:model-dl-multi

Conversation

@mshabunin
Copy link
Copy Markdown
Contributor

❗ This PR supersedes #1127 and #1126

  • split functionality
  • support multiple URLs
  • reduce output
  • updated google drive download mechanism
  • support new yolo models

- split functionality
- support multiple URLs
- reduce output
- support new yolo models
def make_response(self, url, session):
pieces = urlparse(url)
if pieces.netloc in ["docs.google.com", "drive.google.com"]:
return session.get(url, params={'confirm': True}, stream=True, timeout=self.TIMEOUT)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason this simple thing helps to download large files from Google Drive (Ubuntu 22, packaged requests). I'd appreciate additional checks performed by other people using different OSes and locations.


def get_sub(self, ref, arch):
print('** {}'.format(self.filename))
def handle_bad_download(self, filename):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This function has been reduced, I hope the logic is similar to the original. Maybe some cornercases are not handled well, but in general I think it is OK.

filename='onnx/data/output_resnet50_int8.pb'),
]),

# TODO: bad file
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Archive downloaded from GitHub has different checksum and contains different files, perhaps this model and related test should be reviewed separately.

filename='yolov4x-mish.weights'),
Model(
name='GSOC2016-GOTURN', # https://github.com/opencv/opencv_contrib/issues/941
gdrive='1j4UTqVE4EGaUFiK7a5I_CYX7twO9c5br',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We detect Google Drive by URL now.

sha='fcd0fa401c83bf2b29e18239a9c2c989c9b8669d',
filename='onnx/models/yolov7_not_simplified.onnx'),
Model(
name='yolox_s_inf_decoder',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

New model from another PR.

…multiple URLs - reduce output - support new yolo models
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalov asmorkalov merged commit 96169f0 into opencv:4.x Dec 11, 2023
@mshabunin mshabunin deleted the model-dl-multi branch December 11, 2023 14:53
@fengyuentau
Copy link
Copy Markdown
Member

How can I put models in dl.opencv.org?

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.

3 participants