noeedc
Add initial implementation of Surgical Contaminent Classifier-Mix with model, config, and inference script
266f0ac
import torch | |
from transformers import AutoModel, AutoConfig | |
from torchvision import transforms | |
from PIL import Image | |
import os | |
os.chdir(os.path.dirname(os.path.abspath(__file__))) | |
# Load model and config | |
model = AutoModel.from_pretrained( | |
"./classifier-mix", # or path to your model directory | |
trust_remote_code=True | |
) | |
model.eval() | |
# Load and preprocess image | |
img = Image.open("classifier-mix/sample_img.png").convert("RGB") | |
outputs = model(img) | |
print("Predicted class:", outputs[0]['label']) | |
print("Confidences:", outputs[0]['confidences']) |