Instructions to use DQLiu/rrferrglgf-NLP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DQLiu/rrferrglgf-NLP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DQLiu/rrferrglgf-NLP")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DQLiu/rrferrglgf-NLP") model = AutoModelForCausalLM.from_pretrained("DQLiu/rrferrglgf-NLP") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use DQLiu/rrferrglgf-NLP with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DQLiu/rrferrglgf-NLP" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DQLiu/rrferrglgf-NLP", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/DQLiu/rrferrglgf-NLP
- SGLang
How to use DQLiu/rrferrglgf-NLP with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "DQLiu/rrferrglgf-NLP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DQLiu/rrferrglgf-NLP", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "DQLiu/rrferrglgf-NLP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DQLiu/rrferrglgf-NLP", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use DQLiu/rrferrglgf-NLP with Docker Model Runner:
docker model run hf.co/DQLiu/rrferrglgf-NLP
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
MobileNetV2
MobileNetV2 是在分辨率 224x224 的 ImageNet-1k 数据集上预训练的图像分类模型。https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet
我们开发了一个 AMD Ryzen AI (https://ryzenai.docs.amd.com/en/latest/) 支持的修改版本 - https://huggingface.co/models?search=mobilenet_v2
详情可参照 https://huggingface.co/amd/mobilenet_v2_1.0_224
安装
按照 https://ryzenai.docs.amd.com/en/latest/inst.html 为 Ryzen AI 准备环境。
运行以下脚本安装pre-requisites包
pip install -r requirements.txt
推理
推理一张图片
import sys
import onnxruntime
import torch
import torchvision.transforms as transforms
from PIL import Image
image_path = sys.argv[1]
onnx_model = sys.argv[2]
normalize = transforms.Normalize(
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
img_transformer = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
normalize])
img_tensor = img_transformer(Image.open(image_path)).unsqueeze(0)
img_tensor = torch.permute(img_tensor, (0, 2, 3, 1))
so = onnxruntime.SessionOptions()
ort_session = onnxruntime.InferenceSession(
onnx_model, so,
providers=['CPUExecutionProvider'],
provider_options=None)
input = img_tensor.numpy()
ort_input = {ort_session.get_inputs()[0].name: input}
output = ort_session.run(None, ort_input)
top5_probabilities, top5_class_indices = torch.topk(torch.nn.functional.softmax(torch.tensor(output[0])), k=5)
vaip_config.json 来自于Ryzen AI 安装包 https://ryzenai.docs.amd.com/en/latest/inst.html, voe-4.0-win_amd64 of ryzen-ai-sw-1.0.zip.
使用 eval_onnx.py 推理 ImageNet validation dataset (50,000 Images).
测试量化模型CPU
python eval_onnx.py --onnx_model=./mobilenetv2_int8.onnx --data_dir=./{DATA_PATH}
测试量化模型IPU
python eval_onnx.py --onnx_model=./mobilenetv2_int8.onnx --data_dir=./{DATA_PATH} --ipu --provider_config Path\To\vaip_config.json
Metric Accuracy on IPU
top1& top5 accuracy 75.62% / 92.52%
DATA_PATH: ImageNet validation目录
引用
@article{MobileNet v2,
author = {Mark Sandler and
Andrew G. Howard and
Menglong Zhu and
Andrey Zhmoginov and
Liang{-}Chieh Chen},
title = {MobileNetV2: Inverted Residuals and Linear Bottlenecks},
year = {2018},
url = {http://arxiv.org/abs/1801.04381},
}
- Downloads last month
- -