Skip to content

Add a new tutorial: Building a Flask API server with PyTorch #537

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

Merged
merged 15 commits into from
Aug 1, 2019

Conversation

avinassh
Copy link
Contributor

I was writing this for my blog, however, I noticed that PyTorch Tutorials does not have one on building an API. So I am submitting here. My apologies, since I did not discuss this here first. I think PyTorch Tutorial could really use this 😄

@netlify
Copy link

netlify bot commented Jun 20, 2019

Deploy preview for pytorch-tutorials-preview ready!

Built with commit 1401e89

https://deploy-preview-537--pytorch-tutorials-preview.netlify.com

@soumith
Copy link
Member

soumith commented Jun 24, 2019

@jeffreyksmithjr for review. Questions to ask:

  • do you want to include this in tutorials?
  • if you do, any changes you would request on the current draft of the tutorial?

@soumith soumith requested a review from jeffreyksmithjr June 24, 2019 06:01
@avinassh
Copy link
Contributor Author

Hey @jeffreyksmithjr, any update on this?

@jeffreyksmithjr
Copy link

Thanks very much for thinking to add this @avinassh . I didn't see the notification before. I will review this shortly.

Copy link

@jeffreyksmithjr jeffreyksmithjr left a comment

Choose a reason for hiding this comment

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

Lots of tiny easy things to do in one pass. A few are very optional.

transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(
[0.485, 0.456, 0.406],

Choose a reason for hiding this comment

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

I know that you individually are not the source of these magic numbers within this codebase, but I still wish that their origin were more clearly called out. At least some sort of pointer about where they come from.

@jeffreyksmithjr
Copy link

jeffreyksmithjr commented Jul 2, 2019

Thanks very much @avinassh for this well-conceived tutorial. I have a bunch of small things around clarity and language. Overall, this is a valuable contribution. Once we've got it wrapped up, I want to point to this from other locations as well, to help PT users find this resource.

@jspisak
Copy link
Contributor

jspisak commented Jul 30, 2019

@avinassh - any update on this one? We'd like to merge this by next week for the Summer Hack..

cc @brianjo @jlin27

@avinassh
Copy link
Contributor Author

avinassh commented Jul 30, 2019

somehow I missed it. Really sorry. I will update the PR now.

@avinassh
Copy link
Contributor Author

@jeffreyksmithjr Thank you so much for the PR review. Since I am a non-native English speaker, I ended up making a lot of grammatical mistakes.

I have fixed the PR as per the review suggestions.

Only one thing left is about transforms mean/std deviation magic numbers - #537 (comment)

I have provided a link to torchvision's model doc, but it doesn't explain either how/why about those numbers

Could you suggest me, what to add?

@avinassh
Copy link
Contributor Author

@jspisak I have updated the PR :D

@jspisak
Copy link
Contributor

jspisak commented Jul 30, 2019

@avinassh - thanks!! @jeffreyksmithjr - take a look and merge?

# method? Or why it is a global variable? Loading a model can be an
# expensive operation, memory, CPU wise. If we loaded the model in the
# ``get_prediction`` method, then it will get unnecessarily loaded every
# Did you notice that why ``model`` variable is not part of ``get_prediction``

Choose a reason for hiding this comment

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

why still is incorrect. It should just be Did you notice that model..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, somehow I missed it. Sent another PR #583 to fix it.

@jspisak jspisak merged commit 18cada0 into pytorch:master Aug 1, 2019
@jspisak
Copy link
Contributor

jspisak commented Aug 1, 2019

Merging per Jeff's go ahead..

@jeffreyksmithjr
Copy link

jeffreyksmithjr commented Aug 1, 2019

I think this a great tutorial, and I really appreciate you writing it @avinassh . Thanks for your patience with my various nits around writing style. Your solution to the magic numbers issue seems reasonable, since it doesn't originate in your work. Thank you for taking my feedback and getting this in. It turned out great and will be an asset to the community.

@avinassh
Copy link
Contributor Author

avinassh commented Aug 1, 2019

Thank you so much @jeffreyksmithjr! It was really fun writing it. Thanks for your feedback, it was very helpful and I learnt quite a few things about writing a good tutorial :D

@avinassh avinassh deleted the rest-api branch August 1, 2019 17:45
@avinassh
Copy link
Contributor Author

avinassh commented Aug 1, 2019

Also, may I know when this will go live on https://pytorch.org/tutorials

@soumith
Copy link
Member

soumith commented Aug 1, 2019

it should be live now, as soon as the CI finishes the job and pushes to the site.

@brianjo brianjo mentioned this pull request Aug 1, 2019
rodrigo-techera pushed a commit to Experience-Monks/tutorials that referenced this pull request Nov 29, 2021
Add a new tutorial: Building a Flask API server with PyTorch
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.

4 participants