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
74e6111b
Unverified
Commit
74e6111b
authored
Nov 15, 2021
by
NielsRogge
Committed by
GitHub
Nov 15, 2021
Browse files
Fix test and docs (#14399)
parent
4ce74edf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
src/transformers/models/vit/modeling_tf_vit.py
src/transformers/models/vit/modeling_tf_vit.py
+2
-1
tests/test_modeling_tf_vit.py
tests/test_modeling_tf_vit.py
+1
-1
No files found.
src/transformers/models/vit/modeling_tf_vit.py
View file @
74e6111b
...
@@ -795,6 +795,7 @@ class TFViTForImageClassification(TFViTPreTrainedModel, TFSequenceClassification
...
@@ -795,6 +795,7 @@ class TFViTForImageClassification(TFViTPreTrainedModel, TFSequenceClassification
Examples::
Examples::
>>> from transformers import ViTFeatureExtractor, TFViTForImageClassification
>>> from transformers import ViTFeatureExtractor, TFViTForImageClassification
>>> import tensorflow as tf
>>> from PIL import Image
>>> from PIL import Image
>>> import requests
>>> import requests
...
@@ -809,7 +810,7 @@ class TFViTForImageClassification(TFViTPreTrainedModel, TFSequenceClassification
...
@@ -809,7 +810,7 @@ class TFViTForImageClassification(TFViTPreTrainedModel, TFSequenceClassification
>>> logits = outputs.logits
>>> logits = outputs.logits
>>> # model predicts one of the 1000 ImageNet classes
>>> # model predicts one of the 1000 ImageNet classes
>>> predicted_class_idx = tf.math.argmax(logits, axis=-1)[0]
>>> predicted_class_idx = tf.math.argmax(logits, axis=-1)[0]
>>> print("Predicted class:", model.config.id2label[predicted_class_idx])
>>> print("Predicted class:", model.config.id2label[
int(
predicted_class_idx
)
])
"""
"""
inputs
=
input_processing
(
inputs
=
input_processing
(
func
=
self
.
call
,
func
=
self
.
call
,
...
...
tests/test_modeling_tf_vit.py
View file @
74e6111b
...
@@ -371,7 +371,7 @@ class TFViTModelIntegrationTest(unittest.TestCase):
...
@@ -371,7 +371,7 @@ class TFViTModelIntegrationTest(unittest.TestCase):
@
slow
@
slow
def
test_inference_image_classification_head
(
self
):
def
test_inference_image_classification_head
(
self
):
model
=
TFViTForImageClassification
.
from_pretrained
(
"google/vit-base-patch16-224"
,
from_pt
=
True
)
model
=
TFViTForImageClassification
.
from_pretrained
(
"google/vit-base-patch16-224"
)
feature_extractor
=
self
.
default_feature_extractor
feature_extractor
=
self
.
default_feature_extractor
image
=
prepare_img
()
image
=
prepare_img
()
...
...
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