Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
1045a36c
Unverified
Commit
1045a36c
authored
Dec 22, 2021
by
Mario Šaško
Committed by
GitHub
Dec 22, 2021
Browse files
Fix pytorch image classification example (#14883)
* Update example * Remove skip in tests
parent
7df4b90c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
examples/pytorch/image-classification/run_image_classification.py
.../pytorch/image-classification/run_image_classification.py
+4
-2
examples/pytorch/test_examples.py
examples/pytorch/test_examples.py
+0
-2
No files found.
examples/pytorch/image-classification/run_image_classification.py
View file @
1045a36c
...
@@ -279,12 +279,14 @@ def main():
...
@@ -279,12 +279,14 @@ def main():
def
train_transforms
(
example_batch
):
def
train_transforms
(
example_batch
):
"""Apply _train_transforms across a batch."""
"""Apply _train_transforms across a batch."""
example_batch
[
"pixel_values"
]
=
[
_train_transforms
(
pil_loader
(
f
))
for
f
in
example_batch
[
"image_file_path"
]]
example_batch
[
"pixel_values"
]
=
[
_train_transforms
(
pil_img
.
convert
(
"RGB"
))
for
pil_img
in
example_batch
[
"image"
]
]
return
example_batch
return
example_batch
def
val_transforms
(
example_batch
):
def
val_transforms
(
example_batch
):
"""Apply _val_transforms across a batch."""
"""Apply _val_transforms across a batch."""
example_batch
[
"pixel_values"
]
=
[
_val_transforms
(
pil_
loader
(
f
))
for
f
in
example_batch
[
"image
_file_path
"
]]
example_batch
[
"pixel_values"
]
=
[
_val_transforms
(
pil_
img
.
convert
(
"RGB"
))
for
pil_img
in
example_batch
[
"image"
]]
return
example_batch
return
example_batch
if
training_args
.
do_train
:
if
training_args
.
do_train
:
...
...
examples/pytorch/test_examples.py
View file @
1045a36c
...
@@ -19,7 +19,6 @@ import json
...
@@ -19,7 +19,6 @@ import json
import
logging
import
logging
import
os
import
os
import
sys
import
sys
import
unittest
from
unittest.mock
import
patch
from
unittest.mock
import
patch
import
torch
import
torch
...
@@ -409,7 +408,6 @@ class ExamplesTests(TestCasePlus):
...
@@ -409,7 +408,6 @@ class ExamplesTests(TestCasePlus):
result
=
get_results
(
tmp_dir
)
result
=
get_results
(
tmp_dir
)
self
.
assertGreaterEqual
(
result
[
"eval_bleu"
],
30
)
self
.
assertGreaterEqual
(
result
[
"eval_bleu"
],
30
)
@
unittest
.
skip
(
"Fix me Nate!"
)
def
test_run_image_classification
(
self
):
def
test_run_image_classification
(
self
):
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
stream_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
logger
.
addHandler
(
stream_handler
)
logger
.
addHandler
(
stream_handler
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment