Views
No views yet
model.ptrequirements.txt contains:1ultralytics
2torch
3opencv-python
4pillowpip install -r requirements.txtYOLOv10 interface, install it after the requirements:1pip install --no-deps \
2 git+https://github.com/THU-MIG/yolov10.git--no-deps option prevents this installation from replacing an already configured PyTorch and CUDA environment.pip install huggingface-hubmodel.pt from this repository and place it in the working directory.1import os
2
3from ultralytics import YOLOv10
4
5
6def load_trusted_checkpoint(checkpoint_path: str) -> YOLOv10:
7 """Load the trusted MedPMC full-object YOLOv10 checkpoint."""
8 variable = "TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD"
9 previous_value = os.environ.get(variable)
10
11 os.environ[variable] = "1"
12
13 try:
14 model = YOLOv10(checkpoint_path)
15 finally:
16 if previous_value is None:
17 os.environ.pop(variable, None)
18 else:
19 os.environ[variable] = previous_value
20
21 return model
22
23
24model = load_trusted_checkpoint("model.pt")
25
26results = model.predict(
27 source="path/to/images",
28 save=True,
29 save_crop=True,
30 save_txt=True,
31 batch=1,
32 conf=0.5,
33)1import os
2
3from huggingface_hub import hf_hub_download
4from ultralytics import YOLOv10
5
6
7def load_trusted_checkpoint(checkpoint_path: str) -> YOLOv10:
8 """Load the trusted MedPMC full-object YOLOv10 checkpoint."""
9 variable = "TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD"
10 previous_value = os.environ.get(variable)
11
12 os.environ[variable] = "1"
13
14 try:
15 model = YOLOv10(checkpoint_path)
16 finally:
17 if previous_value is None:
18 os.environ.pop(variable, None)
19 else:
20 os.environ[variable] = previous_value
21
22 return model
23
24
25checkpoint_path = hf_hub_download(
26 repo_id="Yale-BIDS-Chen/medpmc-multi-fig-separation-yolov10",
27 filename="model.pt",
28)
29
30model = load_trusted_checkpoint(checkpoint_path)
31
32results = model.predict(
33 source="path/to/images",
34 save=True,
35 save_crop=True,
36 save_txt=True,
37 batch=1,
38 conf=0.5,
39)model.pt checkpoint contains a serialized Ultralytics model object rather than only a tensor state dictionary.torch.load() uses weights_only=True by default. Loading this trusted full-object checkpoint therefore requires explicitly enabling the previous full-object loading behavior.TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=11Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected,
2forcing weights_only=False.1results = model.predict(
2 source="path/to/images",
3 conf=0.5,
4 batch=1,
5 save=True,
6 save_crop=True,
7 save_txt=True,
8 save_conf=True,
9)
10
11for result in results:
12 print(result.boxes.data.cpu().numpy())[x1, y1, x2, y2, confidence, class_id][508.76, 546.65, 722.00, 797.48, 0.9066, 0]class_id x_center y_center width height confidencey difference no greater than 0.05 were grouped into the same row, and boxes within each row were sorted from left to right.1@article{kim2026medpmc,
2 title={MedPMC: A Systematic Framework for Scaling High-Fidelity Medical Multimodal Data for Foundation Models},
3 author={Hyunjae Kim and Dain Kim and Pan Xiao and Serina S. Applebaum and Younjoon Chung and Xuguang Ai and Yu Yin and Roy Jiang and Yuexi Du and Yawen Wei and Yiming Kong and Tuo Guo and Zhiyuan Cao and Mengmeng Du and Yuelei Fu and Yan Hu and Rui Shi and Gui Yang and Kevin W. Jin and Yuntian Liu and Yuxuan Tian and Jonathan Marquez and Zhen Chen and Sheng Zhang and Hoifung Poon and Hua Xu and Jaewoo Kang and Qingyu Chen},
4 journal={arXiv preprint arXiv:2607.07673},
5 year={2026}
6}1@article{wang2024yolov10,
2 title={Yolov10: Real-time end-to-end object detection},
3 author={Wang, Ao and Chen, Hui and Liu, Lihao and Chen, Kai and Lin, Zijia and Han, Jungong and Ding, Guiguang},
4 journal={Advances in neural information processing systems},
5 volume={37},
6 pages={107984--108011},
7 year={2024}
8}