模型:

helenai/microsoft-swin-tiny-patch4-window7-224-ov

英文

microsoft-swin-tiny-patch4-window7-224-ov

这是转换为 OpenVINO 模型的 microsoft/swin-tiny-patch4-window7-224 ,用于加速推断。

对该模型进行推断的示例:

from optimum.intel.openvino import OVModelForImageClassification
from transformers import AutoFeatureExtractor, pipeline

model_id = "helenai/microsoft-swin-tiny-patch4-window7-224"
model = OVModelForImageClassification.from_pretrained(model_id, compile=False)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)

model.reshape(1,3, feature_extractor.size["height"], feature_extractor.size["width"])
model.compile()
ov_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor)

image_url_or_path  = "http://images.cocodataset.org/val2017/000000039769.jpg"
ov_pipe(image_url_or_path)