Instructions to use 0llheaven/detr-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0llheaven/detr-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="0llheaven/detr-finetuned")# Load model directly from transformers import AutoImageProcessor, AutoModelForObjectDetection processor = AutoImageProcessor.from_pretrained("0llheaven/detr-finetuned") model = AutoModelForObjectDetection.from_pretrained("0llheaven/detr-finetuned") - Notebooks
- Google Colab
- Kaggle
Model Card for Model ID
detr-finetuned
Model Description
detr-finetuned This model is a fine-tuned version of facebook/detr-resnet-50 on the 0llheaven/detr-finetuned dataset. This dataset contains images of chapbooks with bounding boxes for the illustrations contained on some of the pages.
Uses
from transformers import AutoImageProcessor, AutoModelForObjectDetection
import torch
from PIL import Image, ImageDraw
import matplotlib.pyplot as plt
# เปิดรูปภาพจากพาธในเครื่อง
url = "../pic/0fda72a2-f383-4f69-af8e-e16a0fbac621.jpg"
image = Image.open(url)
# แปลงรูปภาพเป็น RGB หากเป็น grayscale
if image.mode != "RGB":
image = image.convert("RGB")
processor = AutoImageProcessor.from_pretrained("0llheaven/detr-finetuned")
model = AutoModelForObjectDetection.from_pretrained("0llheaven/detr-finetuned")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
# กรองการทำนายที่มีความแม่นยำมากกว่า 0.9
target_sizes = torch.tensor([image.size[::-1]])
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes)
print(results)
# # วาดกรอบรอบวัตถุที่ตรวจพบในภาพ
draw = ImageDraw.Draw(image)
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
box = [round(i, 2) for i in box.tolist()]
draw.rectangle(box, outline="red", width=3)
draw.text((box[0], box[1]), f"{model.config.id2label[label.item()]}: {round(score.item(), 3)}", fill="red")
# แสดงผลภาพ
plt.figure(figsize=(10, 10))
plt.imshow(image)
plt.axis('off')
plt.show()
- Downloads last month
- 1