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 725 forks source link

What does the manipulation of start and end in shortcut layer mean #31

Open prashkmr opened 5 years ago

prashkmr commented 5 years ago

Positive anotation

        if start > 0: 
            start = start - index
        if end > 0:
            end = end - index

I am unable to understand what this means in the shortcut layer.

v-iashin commented 5 years ago

@prashant030591 this piece may seem strange and quite hard to understand. Actually, the whole 'route' block code can be replaced by the following

    # here we need to deal only with the number of filters 
    elif x['type'] == 'route':
        # route can have one, two, or more sources
        # first, let's make them to be ints
        routes = [int(route) for route in x['layers'].split(',')]
        # then, sum the number of filters from at each mentioned layer
        filters = sum([output_filters[route] for route in routes])

Note: it also helps to deal with a more general case when x['layers'] has more than 2 elements.

@ayooshkathuria it would be nice to have your comments as well. Do you need a PR on this subtle change?