Views
No views yet

pip install ultralytics==8.1.0 torch==2.5.1 transformers huggingface_hub1from transformers import AutoModel
2from PIL import Image
3import torch
4
5# 1. Load model with trust_remote_code=True
6torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
7device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
8model = AutoModel.from_pretrained(
9 "iitolstykh/YOLO-Face-Person-Detector",
10 trust_remote_code=True,
11 dtype=torch_dtype,
12).to(device)
13
14# 2. Load image (You can use URL, PIL.Image or np.ndarray)
15image = Image.open("path/to/your/image.jpg")
16# image = cv2.imread("path/to/your/image.jpg")
17
18# 3. Perform inference
19results = model(image, conf=0.4, iou=0.7)[0]
20
21# 4. Process results
22print("Found objects:", [results.names[int(det.cls)] for det in results.boxes])
23print("Boxes:", results.boxes)
24# render_result(model=model.yolo, image=image, result=results).show()1from ultralytics import YOLO
2from huggingface_hub import hf_hub_download
3import torch
4
5# 1. Download model weights
6model_path = hf_hub_download(
7 repo_id="iitolstykh/YOLO-Face-Person-Detector",
8 filename="yolov8x_person_face.pt",
9 repo_type="model"
10)
11
12# 2. Load model
13torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
14device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
15model = YOLO(model_path)
16model.fuse()
17if torch_dtype is torch.float16:
18 model.model = model.model.half()
19model.to(device)
20
21# 3. Perform inference
22image = 'https://variety.com/wp-content/uploads/2023/04/MCDNOHA_SP001.jpg'
23results = model.predict(image, conf=0.4, iou=0.7, half=torch_dtype is torch.float16)
24
25# 4. Show results
26for result in results:
27 boxes = result.boxes
28 print("Found objects:", [result.names[int(c)] for c in boxes.cls])pip install ultralyticsplus==0.1.01from ultralyticsplus import YOLO, render_result
2
3# 1. Load model
4model = YOLO('iitolstykh/YOLO-Face-Person-Detector')
5
6# 2. Set model parameters
7model.overrides['conf'] = 0.4
8model.overrides['iou'] = 0.7
9model.overrides['max_det'] = 100
10
11# 3. Set image (You can use URL, PIL.Image or np.ndarray)
12image = 'https://variety.com/wp-content/uploads/2023/04/MCDNOHA_SP001.jpg'
13
14# 4. Perform inference
15results = model.predict(image)
16
17# 5. Show results
18print("Found objects:", [results[0].names[int(det.cls)] for det in results[0].boxes])
19render = render_result(model=model, image=image, result=results[0])
20render.show()1@article{mivolo2023,
2 Author = {Maksim Kuprashevich and Irina Tolstykh},
3 Title = {MiVOLO: Multi-input Transformer for Age and Gender Estimation},
4 Year = {2023},
5 Eprint = {arXiv:2307.04616},
6}1@article{mivolo2024,
2 Author = {Maksim Kuprashevich and Grigorii Alekseenko and Irina Tolstykh},
3 Title = {Beyond Specialization: Assessing the Capabilities of MLLMs in Age and Gender Estimation},
4 Year = {2024},
5 Eprint = {arXiv:2403.02302},
6}1@article{cerberusdet,
2 Author = {Irina Tolstykh,Michael Chernyshov,Maksim Kuprashevich},
3 Title = {CerberusDet: Unified Multi-Dataset Object Detection},
4 Year = {2024},
5 Eprint = {arXiv:2407.12632},
6}