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

Update README.md #2010

Merged
merged 2 commits into from Sep 14, 2022
Merged

Update README.md #2010

merged 2 commits into from Sep 14, 2022

Conversation

KexinFeng
Copy link
Contributor

Description

Make the snippet code easier to read and attractive to users.

README.md Outdated
try (Predictor<Image, Classifications> predictor = model.newPredictor()) {
Image img = ImageFactory.getInstance().fromUrl("http://..."); // read image
Classifications result = predictor.predict(img);
ZooModel<Image, Classifications> model = criteria.loadModel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we remove try-catch?

It's better show real code here. We could improve it like:

    Image img = ImageFactory.getInstance().fromUrl("http://..."); // read image
    try (ZooModel<Image, Classifications> model = criteria.loadModel();
         Predictor<Image, Classifications> predictor = model.newPredictor()) {
         Classifications result = predictor.predict(img);
         // get the classification and probability
         ...
    }

Change-Id: Icf7d1be95453ddc5273594c37d68b2f4700a66c8
@KexinFeng KexinFeng merged commit 2293361 into deepjavalibrary:master Sep 14, 2022
@KexinFeng KexinFeng deleted the code_snippet branch October 31, 2022 16:42
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

2 participants