lindevs / yolov8-face

Pre-trained YOLOv8-Face models.
24 stars 4 forks source link

How to use the Pytorch models? #1

Closed johan-irreverentlabs closed 2 months ago

johan-irreverentlabs commented 2 months ago

I'm trying to load the Pytorch model:

model = YOLO('yolov8m-face-lindevs.pt')

I'm getting the following error:

Dataset 'train/data/widerface.yaml' error ❌ 'train/data/widerface.yaml' does not exist

It seems to assume something about my directory structure. I did not clone this repository. I'm just trying to reuse the model in my own project. Can I specify a different path for this file?

lindevs commented 2 months ago

You can use the PyTorch model in your project. You can find a simple code example in the predict.py file. I recently tested the model by creating a new project, and it works as expected. Install dependencies pip install ultralytics and run the code:

from ultralytics import YOLO
from PIL import Image

model = YOLO('yolov8m-face-lindevs.pt')
results = model.predict(
    'https://raw.githubusercontent.com/lindevs/yolov8-face/master/data/images/bus.jpg',
    imgsz=640,
    conf=0.75,
    iou=0.7,
    device='cpu',
    verbose=False
)

img = results[0].plot()
img = Image.fromarray(img[..., ::-1])
img.show()
johan-irreverentlabs commented 2 months ago

Thanks!