Coder Social home page Coder Social logo

Negative Samples about libfacedetection.train HOT 13 OPEN

shiqiyu avatar shiqiyu commented on June 9, 2024
Negative Samples

from libfacedetection.train.

Comments (13)

ShiqiYu avatar ShiqiYu commented on June 9, 2024

Use the score to filter out

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

Sir the confidence is high for the false detection, is there a way to add negative samples in training

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

Also increasing the confidence decreases the detection rate too

from libfacedetection.train.

ShiqiYu avatar ShiqiYu commented on June 9, 2024

you can show some detetection results with the confidence scores.

from libfacedetection.train.

vladkol avatar vladkol commented on June 9, 2024

I noticed this when detection resolution is higher than the network was trained with. When resizing images to 320 before detection (and priors are made with that as well), I'm getting expected results.

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

@ShiqiYu Sir I have trained the model (original caffe yunetv1) on wider dataset, (I have modified the pytorch model to match the original caffe v1 model), and in this model testing I am experiencing false positives, may be the model is too simple to handle such complex cases, that's why i am asking if you can help in adding negative samples. I am thinking of adding hand images with bounding box and class label as background in training data but getting error as
RuntimeError: invalid argument 2: non-empty vector or matrix expected at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:31
how can i modify the multibox loss function in this case to support images only with background label

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

ALL_yunet_epoch_4910 65_441
This image has detection on hand with 86% confidence

from libfacedetection.train.

ShiqiYu avatar ShiqiYu commented on June 9, 2024

As suggested by @vladkol , you can resize the image to a smaller one, then detect it.

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

i am doing detection at 160x120 dimension, i just want to know the way i can modify the multiloss function to accept negative samples

from libfacedetection.train.

boarder8383 avatar boarder8383 commented on June 9, 2024

Got the exact same issue here. I've already resized to 320 and still got tons of false positives, like the back of the head dog faces etc. It will be very helpful to have negative examples as training inputs.

from libfacedetection.train.

ShiqiYu avatar ShiqiYu commented on June 9, 2024

from libfacedetection.train.

boarder8383 avatar boarder8383 commented on June 9, 2024

Need to collect again. I do see hard negative examples code inside multibox_loss.py. Will you be able to share a version that takes negative examples inputs ?

Can you provide the image to test and debug?

On Sun, Sep 6, 2020 at 11:52 PM boarder8383 @.***> wrote: Got the exact same issue here. I've already resized to 320 and still got tons of false positives, like the back of the head etc. It will be very helpful to have negative examples as training inputs. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWR4HISG6STMBVQFV554YLSEOV2ZANCNFSM4NSPJI7A .

Need to

from libfacedetection.train.

PhenomenalOnee avatar PhenomenalOnee commented on June 9, 2024

So We need to do some changes to train with negative samples in data.py and multibox_loss.py

In file data.py
In class PreProc , if we pass an image with label index == 0, we can return empty numpy,
if int(labels_t[0]) == 0:
return image_t, np.empty(0)
In the xml file, you can pass background as label for negative images

In multiloss.py
In line where we parse the batches, we need to compare the size of the target
If empty array is encountered we can initialize 0 valued arrays
for idx in range(num):
if len(targets[idx]) < 1 :
#print(targets[idx])
#print("Amazing")
truths = torch.zeros(1,4)
truths = truths.cuda()
labels = torch.zeros(1,1)
labels = labels.cuda()
else :
truths = targets[idx][:, 0:4].data
labels = targets[idx][:, -1].data

You can also perform this initialization of 0-valued arrays in data.py.

Now comes the part what if all items in a batch contains negative samples, than we will have error in calcualting crossentropy because we are calculating neg_indexes based on pos_indexes and if pos_index is 0 we get 0 neg_indexes and empty array is passed in crossentropy
To pass that , i have initialized a tensor when i get this situation like

num_pos = pos.long().sum(1, keepdim=True)
num_neg = torch.clamp(self.negpos_ratio*num_pos, max=pos.size(1)-1)
#######ERRO HANDLE#########
if num_neg.sum().item() == 0.0:
print('++++++++++++++++++++++++++EMPTY',num_neg.size(),num_neg)
p = torch.tensor(np.array([[100]]),dtype=torch.int64)
num_neg = torch.clamp(p.expand_as(num_pos), max=pos.size(1)-1)
num_neg = num_neg.to('cuda:0')
##########################

from libfacedetection.train.

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.