gihakkk/mobilevit_model
By gihakkk · ↓ 3 · ♥ 0 · Updated 2025-01-04
What's in this repo
This page lists the files in gihakkk/mobilevit_model, including mobilevit_model.onnx.
- 1 ONNX models (.onnx files)
- 6 files, including 2 .json, 1 .md, 1 .onnx, 1 .safetensors
- Last updated 2025-01-04
ONNX files
| File | Size | Download |
|---|---|---|
| mobilevit_model.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
사용예시
import onnxruntime as ort
import numpy as np
from transformers import AutoFeatureExtractor
from PIL import Image
# ONNX 모델 경로
onnx_model_path = r'C:\mobilevit_model.onnx'
# ONNX 런타임 세션 초기화
ort_session = ort.InferenceSession(onnx_model_path)
# 새로운 이미지 예측 함수 정의
def predict_image(image_path):
# MobileViT 모델에 맞는 특징 추출기 로드
feature_extractor = AutoFeatureExtractor.from_pretrained("apple/mobilevit-small")
# 이미지를 로드하고 RGB로 변환
image = Image.open(image_path).convert("RGB")
# 이미지를 특징 추출기로 전처리
inputs = feature_extractor(images=image, return_tensors="np")
input_array = inputs['pixel_values'] # ONNX는 Numpy 형식을 사용
# ONNX 모델에 입력 전달 및 추론
ort_inputs = {ort_session.get_inputs()[0].name: input_array}
ort_outputs = ort_session.run(None, ort_inputs)
# 결과 해석
logits = ort_outputs[0]
predicted_class = np.argmax(logits, axis=-1).item()
return "그냥 사진" if predicted_class == 1 else "로맨스 스캠 사진"
# 예측 예시
image_path = r'C:\1234567.jpg'
result = predict_image(image_path)
print(result)
Model info
onnx
safetensors
mobilevit
license:apache-2.0
region:us
↓ 3
♥ 0
Created: 2025-01-04
Updated: 2025-01-04
View on Hugging FaceFiles (6)
.gitattributes
README.md
config.json
mobilevit_model.onnx
ONNX
model.safetensors
preprocessor_config.json
Related models
More from gihakkk
More models
No task type declared.