hailo-ai / hailo_model_zoo

The Hailo Model Zoo includes pre-trained models and a full building and evaluation environment
MIT License
332 stars 46 forks source link

yolov7.hef vs yolov5m_wo_spp_60p.hef #38

Closed MyraBaba closed 2 years ago

MyraBaba commented 2 years ago

Hi,

As far as I know yolov7 faster and more accurate than the yolov5.

In our tests :

gst-launch-1.0 rtspsrc location=rtsp://xxxxx/ISAPI/Streaming/Channels/101 name=src_0 ! decodebin ! videoscale ! video/x-raw, pixel-aspect-ratio=1/1 ! videoconvert ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailonet hef-path=/local/shared_with_docker/yolov7.hef is-active=true batch-size=1 ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailofilter function-name=yolov5 so-path=/local/workspace/tappas/apps/gstreamer/libs/post_processes//libyolo_post.so config-path=/local/workspace/tappas/apps/gstreamer/general/detection/resources/configs/yolov5.json qos=false ! queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailooverlay ! videoconvert ! fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=false -v | grep -e hailo_display -e hailodevicestats

yolov7.hef almost 7 times slower than the yolov5m_wo_spp_60p.hef version.

nadaved1 commented 2 years ago

Hi @MyraBaba, I don't know if YOLOv7 is generally faster than YOLOv5, as there are many flavors, and many git tags for each model. You maybe can guess from the name of the YOLOv5 model that it was optimized for throughput on the Hailo-8, wherein the YOLOv7 we use the 'plain-vanilla' model.

MyraBaba commented 2 years ago

@MyraBaba Thanks,

I just need visdrone classes and their training inference has very good result in yolov7.

Is there any tutorial that trainng the visdrone Set with yolov5 as in used hailo8.

nadaved1 commented 2 years ago

We don't have an off the shelf ready yolov5 trained on visdrone. That said, we have a retrain docker for yolov5 which you can apply on visdrone.

בתאריך יום א׳, 20 בנוב׳ 2022, 18:01, מאת MyraBaba @.***

:

@MyraBaba https://github.com/MyraBaba Thanks,

I just need visdrone classes and their training inference has very good result in yolov7.

Is there any tutorial that trainng the visdrone Set with yolov5 as in used hailo8.

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1321167942, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYDZ7LMASDARB4G2UCLWJJDNTANCNFSM6AAAAAASFKK6PE . You are receiving this because you commented.Message ID: @.***>

MyraBaba commented 2 years ago

Thanks,

I will look and try to re-train .

Best

On 20 Nov 2022, at 21:59, nadaved1 @.***> wrote:

We don't have an off the shelf ready yolov5 trained on visdrone. That said, we have a retrain docker for yolov5 which you can apply on visdrone.

בתאריך יום א׳, 20 בנוב׳ 2022, 18:01, מאת MyraBaba @.***

:

@MyraBaba https://github.com/MyraBaba Thanks,

I just need visdrone classes and their training inference has very good result in yolov7.

Is there any tutorial that trainng the visdrone Set with yolov5 as in used hailo8.

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1321167942, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYDZ7LMASDARB4G2UCLWJJDNTANCNFSM6AAAAAASFKK6PE . You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1321214487, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFRZH3WACJVVHYTQOA7CKLWJJYKLANCNFSM6AAAAAASFKK6PE. You are receiving this because you were mentioned.

MyraBaba commented 2 years ago

@nadaved1 is this the link for retraining :

https://github.com/hailo-ai/hailo_model_zoo/blob/master/training/yolov5/README.rst

nadaved1 commented 2 years ago

Hi @MyraBaba, Yes, I've also went ahead and tried it, this is how it looks on yolov5s after 100 epochs, it looks very good compared to the GT: image

nadaved1 commented 2 years ago

I think that your command is using wrong yaml, you mixed both the 's' and the 'm' variants, also make sure to follow the guidelines to update the 'nc' field to 10 in the data and network yaml that you use.

If you've wanted to use the 'm', this is the command that you will need (in addition to the yaml update): python train.py --img 640 --batch 16 --epochs 100 --data /data/VisDrone.yaml --weights yolov5m.pt http://yolov5s.pt --cfg models/yolov5m_wo_spp.yaml

‫בתאריך יום ג׳, 22 בנוב׳ 2022 ב-10:05 מאת ‪MyraBaba‬‏ <‪ @.***‬‏>:‬

Hi,

I treid :

python train.py --img 640 --batch 16 --epochs 100 --data /data/VisDrone.yaml --weights yolov5s.pt --cfg models/yolov5m_wo_spp.yaml

Optimizer groups: 85 .bias, 93 conv.weight, 82 other Transferred 57/508 items from yolov5s.pt Scanning labels /data/datasets/VisDrone2019-DET-train/labels.cache (6471 found, 0 missing, 0 empty, 4 duplicate, for 6471 ima Traceback (most recent call last): File "train.py", line 469, in train(hyp, tb_writer, opt, device) File "train.py", line 194, in train testloader = create_dataloader(test_path, imgsz_test, total_batch_size, gs, opt, hyp=hyp, augment=False, File "/workspace/yolov5/utils/datasets.py", line 52, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "/workspace/yolov5/utils/datasets.py", line 342, in init labels, shapes = zip(*[cache[x] for x in self.img_files]) ValueError: too many values to unpack (expected 2)

what is the proper steps ?

secondly did you succesfully export hef file?

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1323263709, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYDZSC7NLXCND7X6C7TWJR5GNANCNFSM6AAAAAASFKK6PE . You are receiving this because you were mentioned.Message ID: @.***>

-- Regards, Nadav Eden

MyraBaba commented 2 years ago

so the correct one:

python train.py --img 640 --batch 16 --epochs 100 --data /data/VisDrone.yaml --weights yolov5m.pt --cfg. models/yolov5m_wo_spp.yaml

nadaved1 commented 2 years ago

Yes, that's it. but also update the yaml accordingly..

‫בתאריך יום ג׳, 22 בנוב׳ 2022 ב-15:54 מאת ‪MyraBaba‬‏ <‪ @.***‬‏>:‬

so the correct one:

python train.py --img 640 --batch 16 --epochs 100 --data /data/VisDrone.yaml --weights yolov5m.pt --cfg. models/yolov5m_wo_spp.yaml

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1323714715, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYCQWQB2UVLLKPMC3L3WJTGB7ANCNFSM6AAAAAASFKK6PE . You are receiving this because you were mentioned.Message ID: @.***>

-- Regards, Nadav Eden

MyraBaba commented 2 years ago

Hi @nadaved1

I followed the instruction train :

python3 train.py --img 640 --batch 4 --epochs 400 --data /data/VisDrone.yaml --weights yolov5m.pt --cfg models/Vis_yolov5m_wo_spp.yaml

and convert to hef:

hailomz compile --ckpt /local/shared_with_docker/400epbesty5.onnx --calib-path /local/shared_with_docker/VisDrone2019-DET-train/images/ --yaml /local/workspace/hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov5m_wo_spp.yaml

detection is very caotic:

Screen Shot 2022-11-24 at 01 32 22
nadaved1 commented 2 years ago

Hey, Can you please contact us through hailo.ai/contact-customer-support/

We will be able to better help you

בתאריך יום ה׳, 24 בנוב׳ 2022, 0:36, מאת MyraBaba @.***

:

Hi @nadaved1 https://github.com/nadaved1

I followed the instruction train :

python3 train.py --img 640 --batch 4 --epochs 400 --data /data/VisDrone.yaml --weights yolov5m.pt --cfg models/Vis_yolov5m_wo_spp.yaml

and convert to hef:

hailomz compile --ckpt /local/shared_with_docker/400epbesty5.onnx --calib-path /local/shared_with_docker/VisDrone2019-DET-train/images/ --yaml /local/workspace/hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov5m_wo_spp.yaml

detection is very caotic:

[image: Screen Shot 2022-11-24 at 01 32 22] https://user-images.githubusercontent.com/17505439/203657338-1c2ef6f8-8cce-43a0-b7d2-67e162f470ba.png

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1325734806, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYFNP6C27MV6SWD7GT3WJ2MABANCNFSM6AAAAAASFKK6PE . You are receiving this because you were mentioned.Message ID: @.***>

MyraBaba commented 2 years ago

@nadaved1 can we add image on the customer-support form ?

MyraBaba commented 2 years ago

@nadaved1

before convert tested the best.pt with yolo detect.py , its working correctly. After trasferring hef and running boxes as above .

I think I am missing some resolution or config?

tmyapple commented 2 years ago

Yolov5 training processs , may choose new anchors , corresponding to the dataset you train on. You should look into your pt file , in the detection block… You’ll find there several configurations :

  1. nc - number of classes
  2. Anchors grids - which are actually the new anchors which should be used in the post processing. … by default the models work with the default anchors which are the ones used for the benchmark yolo v5 models trained on coco
MyraBaba commented 2 years ago

@tmyapple Hi,

is --naautoanchors solve the problems ?

python3 train.py --img 640 --batch 4 --epochs 50 --data /data/VisDrone.yaml --weights yolov5m_wo_spp.pt --cfg models/Vis_yolov5m_wo_spp.yaml --noautoanchor

best.pt file is mostly binary

MyraBaba commented 2 years ago

This is the anchors printed from the best.pt

m = model.model[-1]

print(m.anchor_grid.squeeze()) tensor([[[ 3.26953, 4.28516], [ 4.04297, 9.01562], [ 8.03906, 6.88672]],

    [[ 7.71484, 13.76562],
     [16.60938,  8.75781],
     [13.70312, 17.78125]],

    [[28.90625, 15.86719],
     [22.45312, 29.76562],
     [53.62500, 41.53125]]], dtype=torch.float16)

in detection/resources/configs/yolov5.json different anchors and size . According to above one how I can change the yolov5.json ?

Best

On 24 Nov 2022, at 12:54, tmyapple @.***> wrote:

Yolov5 training processs , may choose new anchors , corresponding to the dataset you train on. You should look into your pt file , in the detection block… You’ll find there several configurations :

nc - number of classes Anchors grids - which are actually the new anchors which should be used in the post processing. … by default the models work with the default anchors which are the ones used for the benchmark yolo v5 models trained on coco — Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1326210940, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFRZHZAYLOZNE7ZC7X254TWJ43MPANCNFSM6AAAAAASFKK6PE. You are receiving this because you were mentioned.

MyraBaba commented 2 years ago

@tmyapple Is there any option to take anchors fro the model if exist automatically ?

MyraBaba commented 2 years ago

@tmyapple @nadaved1

I managed to update anchors in yolo.json now the new trained model working. Only the output of the rint(m.anchor_grid.squeeze()) 1 - 2 -3 should written 3 - 2 - 1 in the json.

nadaved1 commented 2 years ago

As an attachment

בתאריך יום ה׳, 24 בנוב׳ 2022, 9:48, מאת MyraBaba @.***

:

@nadaved1 https://github.com/nadaved1 can we add image on the customer-support form ?

— Reply to this email directly, view it on GitHub https://github.com/hailo-ai/hailo_model_zoo/issues/38#issuecomment-1326070835, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBIQYAJT4WIUWKOPMW4QZ3WJ4MTPANCNFSM6AAAAAASFKK6PE . You are receiving this because you were mentioned.Message ID: @.***>