-
Notifications
You must be signed in to change notification settings - Fork 654
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
fix some bugs in pytorch based examples #2009
fix some bugs in pytorch based examples #2009
Conversation
afb3001
to
b04b861
Compare
@@ -40,13 +40,15 @@ public BigGANTranslator(float truncation) { | |||
/** {@inheritDoc} */ | |||
@Override | |||
public Image[] processOutput(TranslatorContext ctx, NDList list) { | |||
NDArray output = list.get(0).addi(1).muli(128).clip(0, 255); | |||
Image[] images; | |||
try (NDArray output = list.get(0).duplicate().addi(1).muli(128).clip(0, 255)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use try for NDArray makes the code looks ugly.
We generally don't use try-with-resource in Translator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it - i'll update
@@ -52,7 +52,10 @@ public static void main(String[] args) throws IOException, ModelException, Trans | |||
Image input = ImageFactory.getInstance().fromFile(Paths.get(imagePath)); | |||
Image output = transfer(input, artist); | |||
|
|||
logger.info("Using PyTorch Engine. " + artist + " painting generated."); | |||
logger.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info("Using PyTorch Engine. {} painting generated. Image saved in build/output/cyclegan", artist);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
2e491b2
to
98bebce
Compare
98bebce
to
9191194
Compare
Codecov Report
@@ Coverage Diff @@
## master #2009 +/- ##
============================================
- Coverage 72.08% 69.97% -2.12%
- Complexity 5126 5948 +822
============================================
Files 473 587 +114
Lines 21970 26283 +4313
Branches 2351 2860 +509
============================================
+ Hits 15838 18392 +2554
- Misses 4925 6509 +1584
- Partials 1207 1382 +175
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Description
While changing to PyTorch as the default engine I noticed some bugs in examples that rely on PyTorch engine related to #1774.
This changes fixes those examples. I guess this also shows that we are skipping some tests in our current CI, since this issue would have been caught before had the tests run automatically.