Tossy0423 / yolov4-for-darknet_ros

This is the environment in which YOLO V4 is ported to darknet_ros.
MIT License
108 stars 52 forks source link

hello i want use yolov4-tiny #7

Open wnalsqja1 opened 3 years ago

wnalsqja1 commented 3 years ago

hello i am a colleage student in korea

thank you for your code

i want use yolo v4 -tiny because i want to improve fps So, I downloaded the file 'yolov4-tiny.weights'. I modified the file in the following path. (darknet_ros/darknet_ros/config/yolov4.yaml)

weight_file: name: yolov4.weights -> name: yolov4-tiny.weights

but fps did not change

Is this a wrong approach How can i do that

I'd appreciate it if you could answer.

Tossy0423 commented 3 years ago

Dear @wnalsqja1 Thank you for using my repository!

I haven't used yolov4-tiny.weight in this environment. So, I can't judge whether yolov4-tiny is usable or not. However, I am interested in it, so I will try it in my environment:fire:

Please give me some time.

Tossy0423 commented 3 years ago

Dear @wnalsqja1 I’m sorry for the late reply.

I was able to run yolov4-tiny in my environment!! The procedure is shown below.

  1. Download the necessary files.
    
    # Download cfg file
    yolov4-for-darknet_ros/darknet_ros/darknet_ros/yolo_network_config/cfg$ wget https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4-tiny.cfg

Download weights file

yolov4-for-darknet_ros/darknet_ros/darknet_ros/yolo_network_config/weights$ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights

<br>

2. Copy the yaml file for yolov4-tiny. 
```bash
yolov4-for-darknet_ros/darknet_ros/darknet_ros/config$ cp yolov4.yaml yolov4-tiny.yaml


  1. Make changes to the yaml file.
    
    # Before
    config_file:
    name: yolov3.cfg
    weight_file:
    name: yolov3.weights

After

config_file: name: yolov4-tiny.cfg weight_file: name: yolov4-tiny.weights

<br>

4. Copy the launch file. 
```bash
yolov4-for-darknet_ros/darknet_ros/darknet_ros/launch$ cp yolo_v3.launch yolov4-tiny.launch


  1. Change the contents of the launch file.
    
    # Before
    <arg name="network_param_file"         default="$(find darknet_ros)/config/yolov3.yaml"/>

After

<br>

When I tried to run `roslaunch yolov4-for-darknet_ros yolov4-tiny.launch` here, I got the following error and could not run it.
```bash
CUDA Error: out of memory
CUDA Error: out of memory: File exists
darknet_ros: /home/<user>/<ws>/src/yolov4-for-darknet_ros/darknet_ros/darknet/src/utils.c:326: error: Assertion `0' failed.


I modified the batch of yolov4-tiny.cfg downloaded in step 1 from 64 to 1. When I ran it again, it worked.

# Before
batch=64

# After 
batch=1

Screenshot from 2021-02-09 21-56-27

If it doesn't work, please contact us.

wnalsqja1 commented 3 years ago

Thank you for your kindness. Thanks to you, I was able to run the yolov4-tiny. Thank you very much.

aristosamar commented 3 months ago

Changing name of the model file is not this same with changing model. yolov4 and yolov4-tiny have different structures. From what I understand you would need to download tiny version of the model's weight file (yolov4-tiny.conv.29 & yolov4-tiny.cfg) from https://github.com/AlexeyAB/darknet?tab=readme-ov-file and retrain your model.