Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using YOLOv5 on the exDark Dataset #7983

Closed
1 task done
TobiasSchotter opened this issue May 26, 2022 · 6 comments
Closed
1 task done

Using YOLOv5 on the exDark Dataset #7983

TobiasSchotter opened this issue May 26, 2022 · 6 comments
Labels
question Further information is requested

Comments

@TobiasSchotter
Copy link

TobiasSchotter commented May 26, 2022

Search before asking

Question

Hi, I am currently trying to use YOLOv5 on the exDark Dataset and I was wondering if I had to convert all the label files to the xywh-format? Same for the labels to indexes? Or is there a way to use that dataset out of the box? (https://github.com/cs-chan/Exclusively-Dark-Image-Dataset/tree/master/Groundtruth).

I structures the data in the form:

📦exDark
┣ 📂test
┣ 📂train
┣ 📂val
┃ ┗ 📂images
┃ ┗ 📂labels
┗ 📜2015_00001.txt
....

And I removed the first line in each .txt File:

Example:
[1] % bbGt version=3
[2-n] Bicycle 204 28 271 193 0 0 0 0 0 0 0

During training I get:

dataset = LoadImagesAndLabels( File " {PATH} \YOLOv5-vs-RCNN\yolov5\utils\dataloaders.py", line 465, in __init__ labels, shapes, self.segments = zip(*cache.values()) ValueError: not enough values to unpack (expected 3, got 0)

Additional

No response

@TobiasSchotter TobiasSchotter added the question Further information is requested label May 26, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 26, 2022

👋 Hello @TobiasSchotter, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@TobiasSchotter TobiasSchotter closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2022
@glenn-jocher
Copy link
Member

@TobiasSchotter hi there,

You will indeed need to convert the labels to YOLOv5 compatible format (i.e., xywh-format) for the exDark Dataset. You can use our provided conversion script using the Ultralytics Docs at https://docs.ultralytics.com/yolov5/. This will help you convert the labels to indexes. Let us know if you need any further assistance!

Best regards

@BeanBagKing
Copy link

@glenn-jocher - I know this is a little old, but can you be more specific about the location of that conversion script? There's only one mention of "script" on that page, and that's for training. No mention of conversion, the exdark dataset, or bbGt/Bounding box (bb) annotations struct (which I only think is the name of that structure). Nor do I see any script on the yolov5 github (here) that looks like a conversion script, sorry if I missed it. I also tried using roboflow, but it doesn't seem to understand that annotation format (I both tried it, and checked in the listed formats and didn't see it, but I could be doing something wrong).

@glenn-jocher
Copy link
Member

@BeanBagKing you can create a custom script to convert the exDark annotations to YOLO format. Here's a basic example:

def convert_to_yolo_format(input_file, output_file, class_mapping):
    with open(input_file, 'r') as f:
        lines = f.readlines()[1:]  # Skip the first line
    with open(output_file, 'w') as f:
        for line in lines:
            parts = line.split()
            class_name = parts[0]
            bbox = list(map(float, parts[1:5]))
            class_id = class_mapping[class_name]
            # Convert bbox to YOLO format (normalized xywh)
            x_center = (bbox[0] + bbox[2]) / 2
            y_center = (bbox[1] + bbox[3]) / 2
            width = bbox[2] - bbox[0]
            height = bbox[3] - bbox[1]
            f.write(f"{class_id} {x_center} {y_center} {width} {height}\n")

# Example usage
class_mapping = {'Bicycle': 0}  # Add all class mappings
convert_to_yolo_format('input.txt', 'output.txt', class_mapping)

Adjust class_mapping with your dataset's classes. This should help you convert the annotations.

@BeanBagKing
Copy link

Thank you.

For anyone else coming across this via Google like myself, here's what I ended up using: https://github.com/BeanBagKing/YOLO_Training/blob/main/OtherScripts/exdark_converter.py

Doing a bunch of spot checking, it looks like it converted everything nearly correctly. When importing into Roboflow, I got a warning that several bounding boxes went outside the image area and Roboflow corrected those. I looked at a few of those images and nothing was wrong with them. There was at least one image that did not have anything annotated, and at least one image I came across that had the wrong annotation for an object. I think this is an issue with the original dataset though, not in the conversion.

@glenn-jocher
Copy link
Member

Thank you for sharing your solution. It's great to hear that the conversion script worked well for you. If you encounter any further issues or have questions about YOLOv5, feel free to reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants