|
import requests |
|
from PIL import Image |
|
|
|
from optimum.amd.ryzenai import RyzenAIModelForImageClassification |
|
from transformers import AutoFeatureExtractor, pipeline |
|
|
|
|
|
url = "http://images.cocodataset.org/val2017/000000039769.jpg" |
|
image = Image.open(requests.get(url, stream=True).raw) |
|
|
|
quantized_model_path = "mohitsha/transformers-resnet18-onnx-quantized-ryzen" |
|
|
|
|
|
|
|
|
|
vaip_config = ".\\vaip_config.json" |
|
|
|
model = RyzenAIModelForImageClassification.from_pretrained(quantized_model_path, vaip_config=vaip_config) |
|
feature_extractor = AutoFeatureExtractor.from_pretrained(quantized_model_path) |
|
|
|
cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor) |
|
outputs = cls_pipe(image) |
|
print(outputs) |
|
|