Giter VIP home page Giter VIP logo

Comments (4)

glenn-jocher avatar glenn-jocher commented on September 27, 2024

@AlvinBimo23 hello!

It looks like you're having an issue with image recognition during training. Here are a couple of things you could check:

  1. Label Verification: Ensure that the images are labeled correctly in the corresponding annotation files (usually .txt files). Verify whether the class identifiers in the label files match those defined in the classes section of your .yaml file.

  2. Path Format: Confirm the format of the paths specified in your .yaml file. They should be relative to the directory from which you are running the training command unless absolute paths are specified.

Here's a small example of how your .yaml file should look:

train: ../data/images/train/  # path to training images
val: ../data/images/val/      # path to validation images

nc: 1                         # number of classes
names: ['YourClassName']      # class names
  1. File Reading Permissions: Sometimes, issues on specific platforms or environments like vast.ai could be related to reading permissions. Ensure that your dataset directory has the appropriate read permissions.

If the problem persists, consider including the content of your .yaml file and possibly a snippet of your data structure (e.g., a directory tree or a few lines from your annotation files). This can help diagnose the issue more effectively. ๐Ÿ› ๏ธ

Best of luck!

from ultralytics.

AlvinBimo23 avatar AlvinBimo23 commented on September 27, 2024

Hi there, to give more context about my problem. I was using a dataset that i download from roboflow and i tried use itu to train my model and it works, but the problem is the split data ratio are not what i need so I was trying to try split it with my prefered ratio. First i combine all image in one folder and all label in one folder and then i split it manually, the split process are succesful. But when i tried to use the data, the model didnt recognize the all the image file as 'image' but as 'background'. My theories are the model didnt recognize the label data, but i already made sure that all the image file in respective folder has a label file in label folder. Is there any alternative or solution for this ?

*Note : This is my split code

import os
import shutil
import random
from pathlib import Path

def split_data(source_folder, label_folder, train_ratio=0.6, val_ratio=0.2, test_ratio=0.2):
# Convert to Path objects for better path handling
source_folder = Path(source_folder)
label_folder = Path(label_folder)

# Create train, val, test directories
for split in ["Train", "Val", "Test"]:
    os.makedirs(Path(split) / "image", exist_ok=True)
    os.makedirs(Path(split) / "label", exist_ok=True)

# Get list of files in source folder
files = [f for f in source_folder.glob("*.jpg")]
random.shuffle(files)

# Split files into train, val, test sets
num_files = len(files)
num_train = int(train_ratio * num_files)
num_val = int(val_ratio * num_files)
train_files = files[:num_train]
val_files = files[num_train:num_train + num_val]
test_files = files[num_train + num_val:]

# Function to move files
def move_files(file_list, image_dest, label_dest):
    for file in file_list:
        shutil.copy(file, image_dest)
        label_file = label_folder / file.with_suffix(".txt").name
        if label_file.exists():
            shutil.copy(label_file, label_dest)

# Move image and label files to respective directories
move_files(train_files, "Train/image", "Train/label")
move_files(val_files, "Val/image", "Val/label")
move_files(test_files, "Test/image", "Test/label")

Specify source folder and label folder

source_folder = "comb_img"
label_folder = "comb_lbl"

Call the function to split the data

split_data(source_folder, label_folder)

from ultralytics.

glenn-jocher avatar glenn-jocher commented on September 27, 2024

Hi @AlvinBimo23! It looks like you've encountered an issue where the model does not recognize the images as expected and instead treats them as 'background'.

Given that your labels are correctly paired with the images in their respective folders, here's a couple of things you may check:

  • File Path Consistency: Ensure the paths in your .yaml file correctly reference the new split directories. Check that they point to the Train/image, Val/image, and Test/image folders for images and their corresponding label folders.
train: /path/to/Train/image
val: /path/to/Val/image

nc: number_of_classes  # Light check if classes number is correct
names: [list_of_class_names]  # Again, ensure this accurately reflects class labels
  • Label File Format: Confirm the format of your label files (.txt) and make sure they are consistent with the expected YOLO format, which is class id, followed by bbox center x, y normalized by image width, height, and width, and height of bbox also normalized.

  • Precision of Train Test Split: Double-check your split ratios and make sure that each segment (train, val, test) contains both images and their respective labels correctly. Any mismatch here might cause the background-only detection issue.

It might help to visual inspect some of the label files to ensure they are not corrupted or incorrect post-manual splitting. If the configuration seems correct and you're still facing issues, consider a debug step where you sample and manually check a few label-image pairs from each of the splits to verify the correctness.

Hope this helps! Let me know if there's any improvement or further issues! ๐Ÿ•ต๏ธโ€โ™‚๏ธ

from ultralytics.

github-actions avatar github-actions commented on September 27, 2024

๐Ÿ‘‹ Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO ๐Ÿš€ and Vision AI โญ

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.