Update old existing feature extractor references (#24552)
* Update old existing feature extractor references * Typo * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Address comments from review - update 'feature extractor' Co-authored by: Yih-Dar <2521628+ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -38,7 +38,7 @@ if is_torch_available():
|
||||
if is_vision_available():
|
||||
from PIL import Image
|
||||
|
||||
from transformers import AutoFeatureExtractor
|
||||
from transformers import AutoImageProcessor
|
||||
|
||||
|
||||
class YolosModelTester:
|
||||
@@ -345,16 +345,16 @@ def prepare_img():
|
||||
@require_vision
|
||||
class YolosModelIntegrationTest(unittest.TestCase):
|
||||
@cached_property
|
||||
def default_feature_extractor(self):
|
||||
return AutoFeatureExtractor.from_pretrained("hustvl/yolos-small") if is_vision_available() else None
|
||||
def default_image_processor(self):
|
||||
return AutoImageProcessor.from_pretrained("hustvl/yolos-small") if is_vision_available() else None
|
||||
|
||||
@slow
|
||||
def test_inference_object_detection_head(self):
|
||||
model = YolosForObjectDetection.from_pretrained("hustvl/yolos-small").to(torch_device)
|
||||
|
||||
feature_extractor = self.default_feature_extractor
|
||||
image_processor = self.default_image_processor
|
||||
image = prepare_img()
|
||||
inputs = feature_extractor(images=image, return_tensors="pt").to(torch_device)
|
||||
inputs = image_processor(images=image, return_tensors="pt").to(torch_device)
|
||||
|
||||
# forward pass
|
||||
with torch.no_grad():
|
||||
@@ -375,7 +375,7 @@ class YolosModelIntegrationTest(unittest.TestCase):
|
||||
self.assertTrue(torch.allclose(outputs.pred_boxes[0, :3, :3], expected_slice_boxes, atol=1e-4))
|
||||
|
||||
# verify postprocessing
|
||||
results = feature_extractor.post_process_object_detection(
|
||||
results = image_processor.post_process_object_detection(
|
||||
outputs, threshold=0.3, target_sizes=[image.size[::-1]]
|
||||
)[0]
|
||||
expected_scores = torch.tensor([0.9994, 0.9790, 0.9964, 0.9972, 0.9861]).to(torch_device)
|
||||
|
||||
Reference in New Issue
Block a user