Closed akshaylamba closed 6 years ago
I'm NOT using Multiscale Training.
Yes, I have the pre-trained weights on VOC data. It's here https://github.com/experiencor/basic-yolo-keras/issues/6.
I think that 300 images are good enough if you use the pre-trained weights and extensive data augmentation.
@experiencor ...Thanks For your Suggestion ...
Is there a Difference in Weights Downloaded as tiny-yolo-voc.weights and the link you provided...
and also apart from the Data augmentation you wrote in your code ..What Other data augmentation do u suggest...
They are identical. For best result, you may look at object detection code by Google for more advanced data augmentation https://github.com/tensorflow/models/blob/master/object_detection/core/preprocessor.py.
Thanks for your reply... Also does the Code have an implementation for Anchor Boxes like Faster RCNN ..I Suppose YOLO V2 has tried implementing anchor boxes like Faster RCNN .... Have we Implemented KMean to select the box.
Pls Let me know your Views ...
Yes, the anchor boxes are implemented in YOLOv2 and my version too. A set of 5 anchor boxes is used.
Thanks For your Reply... Below is the Detection Result of the Model
The Threshold is set to 0.20 ..How Can I Increase the Threshold to 0.4-0.5 and get the same Result...As I Increase the Threshold The Number of Detections Decreases ...I Think Increasing the data May Help ....Pls Suggest Other ways We can achieve this ...
@cosmicad great job! Why do you want to increase the threshold in the first place? The result seems good enough already. Increasing the data always helps, but it takes time. Shorter way is to artificially augment existing images (try to rotate the images, change brightness, add random dropouts, ... like in this https://github.com/aleju/imgaug). In addition, I'm in the process of coding up a new loss function, which may improve the result. Stay tuned.
I see that your case is highly unbalanced. The best way I know of to deal with this issue to penalize the classification loss differently for different classes. You can try to change the following 2 lines that define the weights of the classification errors for that purpose:
weight_prob = tf.concat(CLASS * [true_box_conf], 4)
weight_prob = SCALE_PROB * weight_prob
I'm very curious with the result. Please update me if possible.
Definitely sir... I would request you to elaborate on the same...with a small example ...I would definitely catch up and come up with a result...
You may want to check the new code. The weights of the classes are specified in CLASS_WEIGHTS = np.ones(CLASS, dtype='float32')
, which is an array of floats (must be float32). The size of the array is exactly the number of the classes. I achieve class re-weighting by the call to tf.gather
in line:
class_mask = y_true[..., 4] * tf.gather(CLASS_WEIGHTS, true_box_class) * CLASS_SCALE
Please note that I have made substantial changes to the loss function to closely follow the original implementation. The architecture has also been changed from the tiny version (9 layers) to the full version (23 layers). The new architecture is much more accurate but will be a bit lower than the old one.
changing the no of labels from 80 to 1 or 2 or 3 Gives the below error :
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-21-b9944f13ff2f> in <module>()
125 # Layer 23
126 x = Conv2D(425, (1,1), strides=(1,1), padding='same', name='conv_23')(x)
--> 127 output = Reshape((GRID_H, GRID_W, BOX, 4 + 1 + CLASS))(x)
128
129 # small hack to allow true_boxes to be registered when Keras build the model
/usr/local/lib/python2.7/dist-packages/keras/engine/topology.pyc in __call__(self, inputs, **kwargs)
619 # Infering the output shape is only relevant for Theano.
620 if all([s is not None for s in _to_list(input_shape)]):
--> 621 output_shape = self.compute_output_shape(input_shape)
622 else:
623 if isinstance(input_shape, list):
/usr/local/lib/python2.7/dist-packages/keras/layers/core.pyc in compute_output_shape(self, input_shape)
374 def compute_output_shape(self, input_shape):
375 return (input_shape[0],) + self._fix_unknown_dimension(
--> 376 input_shape[1:], self.target_shape)
377
378 def call(self, inputs):
/usr/local/lib/python2.7/dist-packages/keras/layers/core.pyc in _fix_unknown_dimension(self, input_shape, output_shape)
368 output_shape[unknown] = original // known
369 elif original != known:
--> 370 raise ValueError(msg)
371
372 return tuple(output_shape)
ValueError: total size of new array must be unchanged
It's fixed. The reason is that I need to vary the number of filters of the last layer according to the number of labels.
I tried your new code...I tried training only one class for detection ... Do not Why the Detection was not Good...May be I am Doing something Wrong with the code...
Below is the Link of Jupyter notebook for your reference :- https://github.com/cosmicad/newyolo_RBC/blob/master/Basic%20Yolo%20Keras.ipynb
Pls review it...It contains all executions with outputs...
I am Thanksful to you for your Efforts and Time you spend in resolving my query ...
Pls let me know your views..
The issue is that the non-predictor anchors tend to be activated at the same time with the predictor anchor. I have the same issue with training with any one class problem. So I think you are doing it right. However, I don't have this issue with training with many classes like in the COCO dataset (80 classes). Seems to be a complex issue, still debugging ...
I got the one class case to work. Just to tweak the parameters. The tweaks that I used to get it working are:
From this:
train_batch = BatchGenerator(train_img, generator_config, jitter=False)
To this:
train_batch = BatchGenerator(train_img, generator_config)
From:
steps_per_epoch = train_batch.get_dateset_size()
To:
steps_per_epoch = train_batch.get_dateset_size() * 5
The last 2 steps are essential to deal with the small size of your dataset.
This is the result: a Raccoon Detector (https://www.youtube.com/watch?v=aibuvj2-zxA) trained on 160 images using the dataset from https://github.com/datitran/raccoon_dataset. This the reference video by the author of the dataset using Google API if you want to know how well the network does (https://www.youtube.com/watch?v=W0sRoho8COI).
So you may try a combination of these tweaks to see if it work. Let me know the results if possible.
tried Using your technique but No Luck .....I do not know what incorrect am I doing ...
I request u to help me out with my dataset once...Pls ...
dataset Link >>> https://github.com/cosmicad/dataset.git Class Label = " RBC "
I am Thanksful to you for your Efforts and Time you spend in resolving my query ...
Regards Akshay
Ok, sure. I take a look.
This is what I get https://github.com/experiencor/basic-yolo-keras/blob/master/examples/Blood%20Cell%20Detection.ipynb.
This result is okay, right?
BTW, is it fine if I put the result of your application to the readme of this repo?
Yes ... I tried Doing Multiclass Detection With the same data set...Below is the results :
If you could Kindly Guide me on Calculating the MAP , Recall / Precision ....
@akshaylamba Congratulate! The result looks stunning to me.
You can use this script to compute mean precision and recall https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/datasets/voc_eval.py. It's a very dirty script. Otherwise, you can use this one https://github.com/cocodataset/cocoapi. You have to convert from the annotations from VOC to COCO to use the latter one.
Hello @experiencor ... I Could Not respond as was Bad on Health... I tried Using your Code for Calculating the MAP , Recall / Precision but could not succeed ..
Can You guide me...
@akshaylamba I'm still finding time to clean my own evaluation code. Will update the code asap.
@akshaylamba You may try the code suggested in https://github.com/experiencor/basic-yolo-keras/issues/27.
@experiencor ... I Have Been Trying to Deploy the YOLO Model On To Web and Create an API for Inference Purpose... Can You Pls Guide me on this...
@akshaylamba I'm not an expert in deployment but I would use some kind of TensorFLow Serving for this. Alternatively, you may also use Amazon SageMaker. And if you want to run the things entirely in browsers, you may check my other repo https://github.com/experiencor/deeplearnjs.
Hi, I am trying to reproduce the same results as above but I am unable to do so with the exact same code provided from your repository...... I get something like the attached image. Thanks for the help in advance!!
Things to note to reproduce my result:
3. Start the training process
.train_times
to 5 or 10.Cheers.
Thank you so much!!!! It is working now!
I was able to reproduce the raccoon results with Full Yolo, but no luck with Tiny Yolo... Is there any additional step that I need to do for Tiny Yolo to work? What I did for Tiny Yolo:
I tried using your provided tiny_yolo_raccoon.h5 for prediction and it was great, what should I do get your tiny yolo results? Thanks again in advance!
It's very tricky to get Tiny Yolo to work given its much less expressive power. You need to play with the 4 scale. Increasing object_scale
and coord_scale
will help. You may also try the new code to generate anchors (gen_anchors.py).
Okay, I will try that. Thank you very much!
@akshaylamba : Where have you found the multiclass annotations for this data set? Could you share the code you ran to obtain the prediction for these 2 images?
Hello
Are you using Multiscale Training of Data..also You have Pretrained Weights on VOC Data ...Below is the Image of Blood Smear :-
I Want to Detect The Purple Color and Red Color Cells...I have Done the Annotations ... I Only have 300 Images With Me with 15-20 Annotation in an Image...What do u Recommand ...