ayooshkathuria / YOLO_v3_tutorial_from_scratch

Accompanying code for Paperspace tutorial series "How to Implement YOLO v3 Object Detector from Scratch"
https://blog.paperspace.com/how-to-implement-a-yolo-object-detector-in-pytorch/
2.32k stars 724 forks source link

what is the difference between your another repo?https://github.com/ayooshkathuria/pytorch-yolo-v3 #3

Closed gittigxuy closed 6 years ago

ayooshkathuria commented 6 years ago

I wrote a tutorial on how to implement the object detector given at my other repo from scratch over at Paperspace

The other repo contains a lot of code that offers much more options for experimentation (such as variants using float16, flags allowing you to run at isolate detection scales) as code that has been written keeping the training code to be written in future in mind.

I created this repo as a accompanying repo for the tutorial, and this code is much simpler, in order to keep the tutorial easier to follow.

gittigxuy commented 6 years ago

So,the complete repo is https://github.com/ayooshkathuria/pytorch-yolo-v3 ?the tutorial repo is just a simple version?

gittigxuy commented 6 years ago

I have a question about route layer

according to your article:

When layers attribute has only one value, it outputs the feature maps of the layer indexed by the value. In our example, it is -4, so the layer will output feature map from the 4th layer backwards from the Route layer.

When layers has two values, it returns the concatenated feature maps of the layers indexed by it's values. In our example it is -1, 61, and the layer will output feature maps from the previous layer (-1) and the 61st layer, concatenated along the depth dimension.

================================== So,if the layer only has one parameter,for example,layer[0]=-4,the result is the previous of the 4th of route layer; if the layer have 2 parameters,for example,layer[0]=-1,layer[1] =36,the result is :from the prior layer of the route layer to the 36th layer? Is it right? but I can not understand code in darknet.py about route layer

default

could you please give an example?

ayooshkathuria commented 6 years ago

@gittigxuy Yep, this repo is a simpler version, and it won't be updated with training and evaluation code.

Okay, onto the route layer. The thing is that the author of YOLO config file hasn't been consistent in providing indexes of the Route layer. Negative indexing means the layer previous from the current layer, whereas positive index means the normal index counting from the first layer.

In the code above, what I've done is try to be a bit uniform and convert all the indexes to relative (negative indexing).

Here's an explanation of what each line does.

if (layers[0]) > 0:
    layers[0] = layers[0] - i

You see, it means, if the first index of the layer, layer[0] is positive, then do subtract it from i which represents the number of the current layer. Suppose if layers[0] is 36, and current layer is 97, then the index is changed to 36 - 97 = -61. This brings every index in a single format, and I don't have to make cases in the forward function of darknet object.

if len(layers) == 1:
    x = outputs[i + layers[0]]

If the layers has only one value, our output is merely the feature map of the layer[0] previous of the current layer. Again, outputs is used to cache feature maps through the loop, and again, if i = -61 in our case, and i = 97 then our output x becomes output[36].

Further the code checks for if layer has two values (-1,36) types. Same thing regarding indexing followed by torch.cat function to concatenate maps.

ayooshkathuria commented 6 years ago

@gittigxuy If your issue got resolved, please be kind as to close the issue, or write an acknowledgment comment so I can 😄