Views
No views yet
hustvl/yolos-smallpip install transformers torch torchvision1from transformers import AutoModelForObjectDetection, AutoFeatureExtractor
2from PIL import Image
3import torch
4
5# Load model and feature extractor
6model_name = "your-username/my-custom-yolos-model"
7model = AutoModelForObjectDetection.from_pretrained(model_name)
8feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
9
10# Load an image
11image = Image.open("path/to/your/image.jpg")
12
13# Preprocess the image
14inputs = feature_extractor(images=image, return_tensors="pt")
15pixel_values = inputs['pixel_values']
16
17# Perform inference
18model.eval()
19with torch.no_grad():
20 outputs = model(pixel_values=pixel_values)
21
22# Visualize the results
23# (Insert visualization code here)1Copy code
2@misc{my-custom-yolos-model,
3 author = {Your Name},
4 title = {YOLOS Fine-tuned on Balloon Dataset},
5 year = {2024},
6 publisher = {Hugging Face},
7 howpublished = {\url{https://huggingface.co/your-username/my-custom-yolos-model}},
8}