Views
No views yet
| ID | Class |
|---|---|
| 0 | molecule |
| 1 | table |
1from ultralytics import YOLO
2from huggingface_hub import hf_hub_download
3
4weights = hf_hub_download("hanmozhang1984/MolDet-v6c", "best.pt")
5model = YOLO(weights)
6
7results = model("patent_page.png", conf=0.25)
8for box in results[0].boxes:
9 cls = int(box.cls[0])
10 conf = float(box.conf[0])
11 x1, y1, x2, y2 = box.xyxy[0].tolist()
12 print(f"Class {cls}, conf {conf:.2f}, box [{x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f}]")