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

Autodownload pretrained ResNet #136

Merged
merged 6 commits into from
Jan 12, 2021
Merged

Conversation

alexander-g
Copy link
Contributor

@alexander-g alexander-g commented Dec 23, 2020

  • Added checks to .set_parameters()
  • Added weights= parameter to ResNet. Can be a path to a ".pkl" file containing module weights as returned by .get_paramters() or "imagenet" which automatically downloads and caches weights in ~/.elegy/downloads
import PIL, urllib

fname,_ = urllib.request.urlretrieve('https://upload.wikimedia.org/wikipedia/commons/e/e4/A_French_Bulldog.jpg')
im = np.array(PIL.Image.open(fname).resize([224,224])) / np.float32(255)

r18 = elegy.nets.resnet.ResNet18(weights='imagenet')
assert elegy.Model(r18).predict(im[np.newaxis]).argmax() == 245   #ImageNet label #245: French Bulldog

@cgarciae

  • How much of this do you think should be added to tests?
  • The weight files are currently hosted on DropBox. I think that's not a long-term solution. I've heard GitHub offers unlimited file hosting for assets with each realease. Maybe upload them on the next version?

@codecov-io
Copy link

codecov-io commented Dec 23, 2020

Codecov Report

Merging #136 (67d8cee) into master (78777ff) will decrease coverage by 0.40%.
The diff coverage is 87.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
- Coverage   79.25%   78.84%   -0.41%     
==========================================
  Files         110      110              
  Lines        5143     5338     +195     
==========================================
+ Hits         4076     4209     +133     
- Misses       1067     1129      +62     
Impacted Files Coverage Δ
elegy/nets/resnet.py 74.25% <57.89%> (-4.06%) ⬇️
elegy/module.py 90.59% <93.10%> (+1.66%) ⬆️
elegy/model/model_base.py 76.42% <100.00%> (+2.12%) ⬆️
elegy/module_test.py 99.81% <100.00%> (+<0.01%) ⬆️
elegy/nets/resnet_test.py 100.00% <100.00%> (ø)
elegy/losses/loss_modes.py 0.00% <0.00%> (-100.00%) ⬇️
elegy/metrics/metric_modes.py 0.00% <0.00%> (-100.00%) ⬇️
elegy/callbacks/progbar_logger.py 63.52% <0.00%> (-14.44%) ⬇️
elegy/model/model.py 69.17% <0.00%> (-2.88%) ⬇️
elegy/model/__init__.py 100.00% <0.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78777ff...67d8cee. Read the comment docs.

@cgarciae
Copy link
Collaborator

  1. Maybe we can add the image somewhere in the repo or as an asset.
  2. We can create the repo elegy-assets to upload stuff in that case.

@charlielito
Copy link
Collaborator

Another option is to use a cloud based solution like GCP. GCP storage is free up to 10 GB

@cgarciae cgarciae merged commit c09f5cf into poets-ai:master Jan 12, 2021
@alexander-g alexander-g deleted the resnet branch January 15, 2021 12:53
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.

None yet

4 participants