Optimum 文件

RyzenAI模型

您正在檢視的是需要從原始碼安裝。如果您希望使用常規的 pip 安裝,請檢視最新的穩定版本 (v1.27.0)。
Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

RyzenAI模型

optimum.amd.ryzenai.pipeline

< >

( task model: typing.Optional[typing.Any] = None vaip_config: typing.Optional[str] = None model_type: typing.Optional[str] = None feature_extractor: typing.Union[str, ForwardRef('PreTrainedFeatureExtractor'), NoneType] = None image_processor: typing.Union[str, transformers.image_processing_utils.BaseImageProcessor, NoneType] = None use_fast: bool = True token: typing.Union[bool, str, NoneType] = None revision: typing.Optional[str] = None **kwargs ) Pipeline

引數

  • task (str) — 定義將返回哪個管道的任務。可用任務包括:
    • “image-classification”(影像分類)
    • “object-detection”(目標檢測)
  • model (Optional[Any], 預設為 None) — 管道將用於進行預測的模型。這可以是一個模型識別符號或一個預訓練模型的實際例項。如果未提供,將載入指定任務的預設模型。
  • vaip_config (Optional[str], 預設為 None) — 用於 Ryzen IPU 推理的執行時配置檔案。預設配置檔案可在 Ryzen AI VOE 包中找到,在安裝過程中會提取名為 vaip_config.json 的檔案。
  • model_type (Optional[str], 預設為 None) — 模型的模型型別
  • feature_extractor (Union[str, "PreTrainedFeatureExtractor"], 預設為 None) — 管道將用於編碼模型資料的特徵提取器。這可以是一個模型識別符號或一個實際的預訓練特徵提取器。
  • image_processor (Union[str, BaseImageProcessor], 預設為 None) — 管道將用於影像相關任務的影像處理器。
  • use_fast (bool, 預設為 True) — 如果可能,是否使用快速分詞器。
  • token (Union[str, bool], 預設為 None) — 用作遠端檔案 HTTP 持有者授權的令牌。如果為 True,將使用執行 huggingface-cli login 時生成的令牌(儲存在 ~/.huggingface 中)。
  • revision (str, 預設為 None) — 要使用的特定模型版本,指定為分支名稱、標籤名稱或提交 ID。
  • **kwargs — 傳遞給底層管道類的附加關鍵字引數。

返回

流水線

給定任務和模型的指定管道例項。

構建用於各種 RyzenAI 任務的管道的實用方法。

此函式為指定任務建立一個管道,利用給定模型或載入該任務的預設模型。該管道包括影像處理器和模型等元件。

計算機視覺

class optimum.amd.ryzenai.pipelines.TimmImageClassificationPipeline

< >

( model: typing.Union[ForwardRef('PreTrainedModel'), ForwardRef('TFPreTrainedModel')] tokenizer: typing.Optional[transformers.tokenization_utils.PreTrainedTokenizer] = None feature_extractor: typing.Optional[ForwardRef('SequenceFeatureExtractor')] = None image_processor: typing.Optional[transformers.image_processing_utils.BaseImageProcessor] = None processor: typing.Optional[transformers.processing_utils.ProcessorMixin] = None modelcard: typing.Optional[transformers.modelcard.ModelCard] = None framework: typing.Optional[str] = None task: str = '' args_parser: ArgumentHandler = None device: typing.Union[int, ForwardRef('torch.device')] = None torch_dtype: typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None binary_output: bool = False **kwargs )

用法示例

import requests
from PIL import Image

from optimum.amd.ryzenai import pipeline

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

model_id = "mohitsha/timm-resnet18-onnx-quantized-ryzen"

pipe = pipeline("image-classification", model=model_id, vaip_config="vaip_config.json")
print(pipe(image))

class optimum.amd.ryzenai.pipelines.YoloObjectDetectionPipeline

< >

( model: typing.Union[ForwardRef('PreTrainedModel'), ForwardRef('TFPreTrainedModel')] tokenizer: typing.Optional[transformers.tokenization_utils.PreTrainedTokenizer] = None feature_extractor: typing.Optional[ForwardRef('SequenceFeatureExtractor')] = None image_processor: typing.Optional[transformers.image_processing_utils.BaseImageProcessor] = None processor: typing.Optional[transformers.processing_utils.ProcessorMixin] = None modelcard: typing.Optional[transformers.modelcard.ModelCard] = None framework: typing.Optional[str] = None task: str = '' args_parser: ArgumentHandler = None device: typing.Union[int, ForwardRef('torch.device')] = None torch_dtype: typing.Union[str, ForwardRef('torch.dtype'), NoneType] = None binary_output: bool = False **kwargs )

支援的模型型別

  • yolox
  • yolov3
  • yolov5
  • yolov8

用法示例

import requests
from PIL import Image

from optimum.amd.ryzenai import pipeline

img = ".\\image.jpg"
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
img = ".\\image2.jpg"

image = Image.open(img)

model_id = "amd/yolox-s"

detector = pipeline("object-detection", model=model_id, vaip_config="vaip_config.json", model_type="yolox")
detector = pipe(image)
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.