We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I followed the instructions and run the code below provided by the example: import requests from PIL import Image
url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw)
model_id =
but I got error below: AttributeError Traceback (most recent call last) Cell In[3], line 3 1 model = RyzenAIModelForImageClassification.from_pretrained(model_id) 2 feature_extractor = AutoFeatureExtractor.from_pretrained(model_id) ----> 3 cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor, token=token1) 4 outputs = cls_pipe(image)
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines_init_.py:1108, in pipeline(task, model, config, tokenizer, feature_extractor, image_processor, framework, revision, use_fast, token, device, device_map, torch_dtype, trust_remote_code, model_kwargs, pipeline_class, **kwargs) 1105 if device is not None: 1106 kwargs["device"] = device -> 1108 return pipeline_class(model=model, framework=framework, task=task, **kwargs)
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines\image_classification.py:89, in ImageClassificationPipeline.init(self, *args, **kwargs) 88 def init(self, *args, **kwargs): ---> 89 super().init(*args, **kwargs) 90 requires_backends(self, "vision") 91 self.check_model_type( 92 TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES 93 if self.framework == "tf" 94 else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES 95 )
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines\base.py:848, in Pipeline.init(self, model, tokenizer, feature_extractor, image_processor, modelcard, framework, task, args_parser, device, torch_dtype, binary_output, **kwargs) 845 device = -1 847 if is_torch_available() and self.framework == "pt": --> 848 if device == -1 and self.model.device is not None: 849 device = self.model.device 850 if isinstance(device, torch.device):
AttributeError: 'RyzenAIModelForImageClassification' object has no attribute 'device'
The text was updated successfully, but these errors were encountered:
Same error. I am using the example codes from [https://huggingface.co/docs/optimum/main/en/amd/ryzenai/overview] yet I'm still getting errors.
Sorry, something went wrong.
No branches or pull requests
I followed the instructions and run the code below provided by the example:
import requests
from PIL import Image
from transformers import AutoFeatureExtractor, pipeline
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
model_id =
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor)
outputs = cls_pipe(image)
but I got error below:
AttributeError Traceback (most recent call last)
Cell In[3], line 3
1 model = RyzenAIModelForImageClassification.from_pretrained(model_id)
2 feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
----> 3 cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor, token=token1)
4 outputs = cls_pipe(image)
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines_init_.py:1108, in pipeline(task, model, config, tokenizer, feature_extractor, image_processor, framework, revision, use_fast, token, device, device_map, torch_dtype, trust_remote_code, model_kwargs, pipeline_class, **kwargs)
1105 if device is not None:
1106 kwargs["device"] = device
-> 1108 return pipeline_class(model=model, framework=framework, task=task, **kwargs)
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines\image_classification.py:89, in ImageClassificationPipeline.init(self, *args, **kwargs)
88 def init(self, *args, **kwargs):
---> 89 super().init(*args, **kwargs)
90 requires_backends(self, "vision")
91 self.check_model_type(
92 TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
93 if self.framework == "tf"
94 else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
95 )
File ~\anaconda3\envs\ryzenai-1.1-20240608-152949\lib\site-packages\transformers\pipelines\base.py:848, in Pipeline.init(self, model, tokenizer, feature_extractor, image_processor, modelcard, framework, task, args_parser, device, torch_dtype, binary_output, **kwargs)
845 device = -1
847 if is_torch_available() and self.framework == "pt":
--> 848 if device == -1 and self.model.device is not None:
849 device = self.model.device
850 if isinstance(device, torch.device):
AttributeError: 'RyzenAIModelForImageClassification' object has no attribute 'device'
The text was updated successfully, but these errors were encountered: