roboflow / notebooks

Examples and tutorials on using SOTA computer vision models and techniques. Learn everything from old-school ResNet, through YOLO and object-detection transformers like DETR, to the latest models like Grounding DINO and SAM.
https://roboflow.com/models
5.29k stars 820 forks source link

Trainin YOLO-NAS on Custom Dataset with Colab Notebook #122

Closed omerfguzel closed 1 year ago

omerfguzel commented 1 year ago

Search before asking

Notebook name

YOLO-NAS Object Detection

Bug

Caching annotations: 100%|██████████| 2877/2877 [00:01<00:00, 2005.08it/s]
---------------------------------------------------------------------------
EmptyDatasetException                     Traceback (most recent call last)
[<ipython-input-18-fd6cc5dc80cf>](https://localhost:8080/#) in <cell line: 4>()
      2     coco_detection_yolo_format_train, coco_detection_yolo_format_val)
      3 
----> 4 train_data = coco_detection_yolo_format_train(
      5     dataset_params={
      6         'data_dir': dataset_params['data_dir'],

5 frames
[/usr/local/lib/python3.10/dist-packages/super_gradients/training/datasets/detection_datasets/detection_dataset.py](https://localhost:8080/#) in _cache_annotations(self)
    214 
    215         if len(annotations) == 0:
--> 216             raise EmptyDatasetException(
    217                 f"Out of {self.n_available_samples} images, not a single one was found with any of these classes: {self.class_inclusion_list}"
    218             )

EmptyDatasetException: Empty Dataset: Out of 2877 images, not a single one was found with any of these classes: None

Environment

Minimal Reproducible Example

No response

Additional

Getting error when try to run

from super_gradients.training.dataloaders.dataloaders import (
    coco_detection_yolo_format_train, coco_detection_yolo_format_val)

train_data = coco_detection_yolo_format_train(
    dataset_params={
        'data_dir': dataset_params['data_dir'],
        'images_dir': dataset_params['train_images_dir'],
        'labels_dir': dataset_params['train_labels_dir'],
        'classes': dataset_params['classes']
    },
    dataloader_params={
        'batch_size': BATCH_SIZE,
        'num_workers': 2
    }
)

val_data = coco_detection_yolo_format_val(
    dataset_params={
        'data_dir': dataset_params['data_dir'],
        'images_dir': dataset_params['val_images_dir'],
        'labels_dir': dataset_params['val_labels_dir'],
        'classes': dataset_params['classes']
    },
    dataloader_params={
        'batch_size': BATCH_SIZE,
        'num_workers': 2
    }
)

test_data = coco_detection_yolo_format_val(
    dataset_params={
        'data_dir': dataset_params['data_dir'],
        'images_dir': dataset_params['test_images_dir'],
        'labels_dir': dataset_params['test_labels_dir'],
        'classes': dataset_params['classes']
    },
    dataloader_params={
        'batch_size': BATCH_SIZE,
        'num_workers': 2
    }
)

cell on notebook.

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

👋 Hello @omerfguzel, thank you for leaving an issue on Roboflow Notebooks.

🐞 Bug reports

If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.

If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.

💬 Get in touch

Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.

To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.

SkalskiP commented 1 year ago

Hi, @omerfguzel 👋🏻! Thanks a lot for your interest in our repository. My feeling is that your problem is dataset related. Could you share with me a link to your dataset?

omerfguzel commented 1 year ago

Hi, @omerfguzel 👋🏻! Thanks a lot for your interest in our repository. My feeling is that your problem is dataset related. Could you share with me a link to your dataset?

Hi @SkalskiP, here it is: https://app.roboflow.com/nurefsanakk/damaged_building/deploy/1

SkalskiP commented 1 year ago

Hi @omerfguzel 👋🏻! My guess is because your dataset is an instance segmentation dataset - you use polygons to annotate data, while YOLO-NAS is an object detection model - that relies on bounding boxes for training and inference. In general, I'd recommend training the instance segmentation model.

We could come up with some workaround to convert your annotations from polygons to boxes. 💡 It would require adding a few lines of custom code to your notebook. Let me know what you think.

omerfguzel commented 1 year ago

I see, thank you for the support. I think I'll go with an instance segmentation model. I don't think object detection can perform enough to deploy on this dataset. Thank you again @SkalskiP 🙏

SkalskiP commented 1 year ago

No worries, @omerfguzel. I'm happy I was able to help. Try our YOLOv8 segmentation notebook: https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov8-instance-segmentation-on-custom-dataset.ipynb