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

Training with negative and positive data samples #1686

Closed
JaninaMattes opened this issue Feb 16, 2021 · 8 comments
Closed

Training with negative and positive data samples #1686

JaninaMattes opened this issue Feb 16, 2021 · 8 comments
Labels
question Further information is requested Stale

Comments

@JaninaMattes
Copy link

JaninaMattes commented Feb 16, 2021

How can I calculate the loss if I train negative and positive samples?

My negative samples don't come with a label and thus are empty tensor values in my batches. This on the other hand is problematic as anchor boxes, image indices and target classes etc. are required in the current calculation of the loss value for the targets. I read that you have tried training with negative and positive samples. Could you provide some hints on how you solved this? Many thanks in advance!

@JaninaMattes JaninaMattes added the question Further information is requested label Feb 16, 2021
@github-actions
Copy link

github-actions bot commented Feb 16, 2021

👋 Hello @JaninaMattes, thank you for your interest in 🚀 YOLOv3! 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv3 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 YOLOv3 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv3 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

glenn-jocher commented Feb 16, 2021

@JaninaMattes the default training already incorporates all negative and positive samples in all images. To get started see https://docs.ultralytics.com/yolov5/tutorials/train_custom_data

@JaninaMattes
Copy link
Author

Hi @glenn-jocher thank you very much. I had overlooked the update of the instructions. However, one question that still occurs to me. When I output my batches, it looks like I have no negative samples in either a training nor a test batch. My negative and positive samples are stored in my training.txt file as paths to the images, the negative samples do not get a .txt annotation. When I load the data sets, I can see that data sets are loaded without annotation (empty tensors). However, I do not get any negative samples in my training batch.

Could this be due to the sampler? I had previously used a RandomWeightedSampler, but now I use the InfiniteSampler. Do you have any idea how I could solve this problem?

Thank you very much!

@glenn-jocher
Copy link
Member

@JaninaMattes I don't understand what you're asking. A 'negative sample' is a gridpoint in an image that is not assigned to a particular label/target. Every image has negative samples.

@JaninaMattes
Copy link
Author

@glenn-jocher due to the type of my dataset I would like to train my network with 'positive samples', meaning images that contain objects and 'negative samples', images without objects.

@glenn-jocher
Copy link
Member

glenn-jocher commented Feb 18, 2021

@JaninaMattes you're describing every dataset basically. COCO has images with labels and images without labels. You don't have any special requirements, simply train following the normal steps in the Train Custom Data tutorial:

Tutorials

@ardeal
Copy link

ardeal commented Mar 12, 2021

@JaninaMattes ,

For each image, labelled region in the image is treated as positive sample. unlabelled region in the image is treated as negative sample.

if there is no labelled region in the image which is input to the network for training, all region in the image is treated as negative sample.

That is to say, the region in image is either treated as positive or negative.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

3 participants