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

Image prediction using trained model #2392

Merged
merged 17 commits into from
Jun 9, 2023
Merged

Conversation

HemanthSai7
Copy link
Contributor

@HemanthSai7 HemanthSai7 commented Jun 1, 2023

Fixes #1110

Description

This commit enables us to perform image prediction using the saved model. We can now select any image and obtain a prediction for its corresponding label as described in the issue.

Checklist

cc @dreiss @jonas @pietern @svekars

@netlify
Copy link

netlify bot commented Jun 1, 2023

Deploy Preview for pytorch-tutorials-preview ready!

Name Link
🔨 Latest commit 0650b47
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-tutorials-preview/deploys/64836cc02931ad00083c8545
😎 Deploy Preview https://deploy-preview-2392--pytorch-tutorials-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added torchvision Issues relating to image/video tutorials docathon-h1-2023 A label for the docathon in H1 2023 medium and removed cla signed labels Jun 1, 2023
@HemanthSai7
Copy link
Contributor Author

HemanthSai7 commented Jun 1, 2023

Hello, the build failed on visualize_model_upload_image(model_conv,img_path='image_path',model_name='model_name') saying no such directory image_path. How do I fix this?

# the results.
#

def save_and_load_model(model, model_name):
Copy link
Member

Choose a reason for hiding this comment

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

Is this a convoluted way to do a deepcopy?
I think in this case using deepcopy is fine if it works.


def visualize_model_upload_image(model,model_name,img_path):
was_training = model.training
model=save_and_load_model(model,model_name)
Copy link
Member

@kit1980 kit1980 Jun 7, 2023

Choose a reason for hiding this comment

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

Why is this needed? If the original model is not modified by this function.
And the original model is not even used after this function...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I get your point. I'll make the changes as requested following PEP8 guidelines.

Copy link
Member

@kit1980 kit1980 left a comment

Choose a reason for hiding this comment

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

Have you verified that this is working?
Also please address the comments and format the Python code according to PEP8.

@pytorch-bot
Copy link

pytorch-bot bot commented Jun 8, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/2392

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 0650b47:

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Updated the PR following the PEP8 guidelines and made the requested changes
@HemanthSai7
Copy link
Contributor Author

@svekars @kit1980 I have made the requested changes and also formatted the code according to PEP8.

@svekars svekars merged commit a58279c into pytorch:main Jun 9, 2023
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 medium torchvision Issues relating to image/video tutorials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to Inference non-val images in Transfer Learning Tutorial
4 participants