ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.16k stars 3.44k forks source link

Feature-request: YOLOv4-tiny #1350

Closed zbyuan closed 4 years ago

zbyuan commented 4 years ago

Hi! YOLOv4-tiny released: 40.2% AP50, 371 FPS (GTX 1080 Ti) / 330 FPS (RTX 2070) https://github.com/AlexeyAB/darknet/issues/6067 how to support in this project?thanks

github-actions[bot] commented 4 years ago

Hello @zbyuan, thank you for your interest in our work! Ultralytics has open-sourced YOLOv5 at https://github.com/ultralytics/yolov5, featuring faster, lighter and more accurate object detection. YOLOv5 is recommended for all new projects.

To continue with this repo, please visit our Custom Training Tutorial to get started, and see our Google Colab Notebook, Docker Image, and GCP Quickstart Guide for example environments.

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 model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

For more information please visit https://www.ultralytics.com.

glenn-jocher commented 4 years ago

@zbyuan ah, it's really easy. You can use any darknet .cfg file here. So you would just need to find the .cfg you are interested in here: https://github.com/AlexeyAB/darknet/tree/master/cfg

And then you should be able to use it in this repo. To make it easier in the future I'll add the yolov4-tiny.cfg to our own cfg folder today also. Then you just need to git pull and run:

python train.py --cfg cfg/yolov4-tiny.cfg

dengfenglai321 commented 4 years ago

hi I use command as below: python train.py --cfg cfg/yolov4-tiny.cfg

but there are some error: File "/media/cendelian/新加卷/CV/Project/Competition/yyyyyy/xxxxxx/U-YOLOv4-Hat/yolov3-master/utils/parse_config.py", line 49, in parse_model_cfg assert not any(u), "Unsupported fields %s in %s. See https://github.com/ultralytics/yolov3/issues/631" % (u, path) AssertionError: Unsupported fields ['group_id', 'resize'] in cfg/yolov4-tiny-hat.cfg. See https://github.com/ultralytics/yolov3/issues/631

what's problem? could yuou help me

JimLee1996 commented 4 years ago

Maybe there are some differences in [route] layers. Plz see https://github.com/opencv/opencv/issues/17666#issue-645624234.

jas-nat commented 4 years ago

What's the difference among yolov4-tiny.cfg, yolov4-relu.cfg, and yolov4.cfg?

glenn-jocher commented 4 years ago

tiny is a smaller version, relu uses relu activations in place of mish.

JimLee1996 commented 4 years ago

tiny is a smaller version, relu uses relu activations in place of mish.

@glenn-jocher The real reason is that yolov4-tiny model introduce a special [route] block, which has new groups and group_id parameters, demonstrated in https://github.com/opencv/opencv/issues/17666#issue-645624234. I've implemented like this:

class RouteGroup(nn.Module):

    def __init__(self, layers, groups, group_id):
        super(RouteGroup, self).__init__()
        self.layers = layers
        self.multi = len(layers) > 1
        self.groups = groups
        self.group_id = group_id

    def forward(self, x, outputs):
        if self.multi:
            outs = []
            for layer in self.layers:
                out = torch.chunk(outputs[layer], self.groups, dim=1)
                outs.append(out[self.group_id])
            return torch.cat(outs, dim=1)
        else:
            out = torch.chunk(outputs[self.layers[0]], self.groups, dim=1)
            return out[self.group_id]
glenn-jocher commented 4 years ago

@JimLee1996 ah, I see. Then yes the default repo may require some updates in order for it to operate correctly. Does your implementation work well?

JimLee1996 commented 4 years ago

Steady as she goes. However, I've mod it in my personal repo. Here are some changes I made to adapt for yolov4-tiny. Hope it will be helpful. image image image image

wenhaotang commented 4 years ago

@JimLee1996 Thank you for sharing your personal code, I tried your code, and there is still a problem that has not been solved:

AssertionError: Unsupported fields ['resize'] in cfg/yolov4-tiny-hat.cfg. See #631

How do you achieve resize?

JimLee1996 commented 4 years ago

@JimLee1996 Thank you for sharing your personal code, I tried your code, and there is still a problem that has not been solved:

AssertionError: Unsupported fields ['resize'] in cfg/yolov4-tiny-hat.cfg. See #631

How do you achieve resize?

@wenhaotang for inference, add 'resize' in supported list

wenhaotang commented 4 years ago

@JimLee1996 Thank you for sharing your personal code, I tried your code, and there is still a problem that has not been solved: AssertionError: Unsupported fields ['resize'] in cfg/yolov4-tiny-hat.cfg. See #631 How do you achieve resize?

@wenhaotang for inference, add 'resize' in supported list

@JimLee1996 Thank you. The code runs successfully, but the detection result is not satisfactory.

I think there should be some details not implemented in this repo.

Thank you for your reply :)

garvitkhera commented 4 years ago

@wenhaotang @JimLee1996 Hey, I'm also stuck on the same thing for training a single class on tiny yolov4. I'm a little confused as to where do these changes are needed, in which file actually? Thanks!

Gaoang112 commented 4 years ago

hey,is it modified in the model.py file? @JimLee1996

JimLee1996 commented 4 years ago

@Gaoang112 yep

github-actions[bot] commented 4 years ago

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.

GreenTeaHua commented 3 years ago

@JimLee1996 in .cfg, get the resize out, Thank you. everything is ok, except vis.

MuhammadAsadJaved commented 3 years ago

@JimLee1996 can you share your updated fork that can use Yolov4 and v4-tiny? The project is updated so there are different changes.

@GreenTeaHua What do you mean by in .cfg get the resize out? Does it work for you?

MuhammadAsadJaved commented 3 years ago

@JimLee1996 Can you please share that specific branch or your fork? The project is updated and I am confused where i should make changes in new branch to run Yolov4-tiny. Thank you.

JimLee1996 commented 3 years ago

@MuhammadAsadJaved It seems this repo varies a lot compared to the old one. It uses the yolov5 style and is never compatible with the DarkNet's cfg and weight. Check this archived branch https://github.com/ultralytics/yolov3/tree/archive. ;-)

MuhammadAsadJaved commented 3 years ago

ok. Thank you for your response.

MuhammadAsadJaved commented 3 years ago

@JimLee1996 May I ask about the timeline when you forked that project? I can try to find same from other people's forked projects. As the archive versions in the current project are also very different.

You have commented on June 30 2020, but the project version round about that date is also different. So may I ask which fork (estimated date) you forked that project.

JimLee1996 commented 3 years ago

Sorry, I accidentaly lost that code, but I remember it's about May, so maybe this tag https://github.com/ultralytics/yolov3/tree/v7 BTW, the archived brach seems supporting yolov4-tiny.

MuhammadAsadJaved commented 3 years ago

@JimLee1996 OK. Thank you so much. I have trained yolov4-tiny on the darknet project. This archived branch may support only their own yolov4-tiny.cfg. I will try the archived branch again. The release v7 code for model.py is also different from your recommended changes.

Thank you so much for your time.