Converting Labelbox annotation export to YOLO v8 PyTorch

I have around 10k images annotated with bounding boxes. I need to use these annotations in a YOLOv8 object detection model.

How can I convert the Labelbox .json export to a format usable in a YOLOv8 model?

You can use this lib : GitHub - ultralytics/JSON2YOLO: Convert JSON annotations into YOLO format. to convert your Labelbox annotation to Yolo format.
Once done just make sure to create .yaml file that maps your Path accordingly.
This lib was created during Yolo v5 so there are a few things to consider.
Many thanks,
Paul Tancré
Labelbox Support

Thanks for the tip!

I had found this resource and gave it a try, but ran into an error since my images are in a GCP bucket. I integrated Labelbox with my GCP bucket when doing the annotations and thus the Labelbox export lists the location on GCP.

Is there a way to use the script you linked to when images and the export use a GCP bucket?

Because we return the gsutil URI you will need to retrieve assets via your bucket directly using I don’t have a fully working version but you can map the asset with the name of the file in the URI and the asset in your GCP bucket.
Here is a snippet to get all your asset with a valid token :

blobs = storage_client.list_blobs(bucket_name)
bucket_asset_url = []
for blob in blobs:
        # This URL is valid for 15 minutes
        expiration= timedelta(minutes=15),
        # Allow GET requests using this URL.

Then you need to replace in the script :

im_path = img['Labeled Data']

by your map (essentially a valid URL) that can retrieve the image from the bucket directly.

1 Like