Page 1 of 1

Custem yolov5 model yolov5n - Segmentation fault (core dumped)

Posted: 2024-07-24 9:15
by techhitesh
Hello,

Thank you for this forum.
I am trying to make a object detector i tried to get the dataset from roboflow. Then i trained the mode >> converted using yolov5 to rknn to onnx >> then used convert.py to get yolov5n.rknn >> then compiled example and got the c code compiled then when i ran it it gave me this error

Code: Select all

[root@luckfox rknn_yolov5_demo]# ./rknn_yolov5_demo model/yolov5.rknn model/bus.jpg 
load lable ./model/coco_80_labels_list.txt
model input num: 1, output num: 3
input tensors:
  index=0, name=images, n_dims=4, dims=[1, 640, 640, 3], n_elems=1228800, size=1228800, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
output tensors:
  index=0, name=output0, n_dims=4, dims=[1, 80, 80, 36], n_elems=230400, size=230400, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=1, name=343, n_dims=4, dims=[1, 40, 40, 36], n_elems=57600, size=57600, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=2, name=345, n_dims=4, dims=[1, 20, 20, 36], n_elems=14400, size=14400, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
input_attrs[0].size_with_stride=1228800
model is NHWC input fmt
model input height=640, width=640, channel=3
origin size=640x640 crop size=640x640
input image: 640 x 640, subsampling: 4:2:0, colorspace: YCbCr, orientation: 1
Now i will try to load model and image
scale=1.000000 dst_box=(0 0 639 639) allow_slight_change=1 _left_offset=0 _top_offset=0 padding_w=0 padding_h=0
src width=640 height=640 fmt=0x1 virAddr=0x0xa626c000 fd=11
dst width=640 height=640 fmt=0x1 virAddr=0x(nil) fd=3
src_box=(0 0 639 639)
dst_box=(0 0 639 639)
color=0x72
rga_api version 1.10.1_[0]
rknn_run
Segmentation fault (core dumped)

In details steps are here
Training Steps
1. Downloaded dataset

Code: Select all

!pip install roboflow

from roboflow import Roboflow
rf = Roboflow(api_key="fpRIiVCaZT7TFnwC1x0Y")
project = rf.workspace("data-drown").project("datn-kmi9v")
version = project.version(1)
dataset = version.download("yolov5")
2. Train dataset

Code: Select all

!python train.py --img 640 --batch 32 --epochs 10 --data /kaggle/working/yolov5/DATN-1/data.yaml --weights yolov5n.pt
3. Followed these steps to convert the best.pt to onnx and then rknn
https://wiki.luckfox.com/Luckfox-Pico/L ... -RKNN-Test

4. Tested the folder and attached is the datn_.pt file and datn_.onnx file and yolov5.rknn

Re: Custem yolov5 model yolov5n - Segmentation fault (core dumped)

Posted: 2024-07-25 16:37
by techhitesh
Please let me know if anything can be done i have tried all the things.

When i tried to convert my model but then it says dill not found then i needed to install this library and then it converted to onnx

Code: Select all

(yolov5) ml@ml-ts:~/yolov5$ pip show dill
Name: dill
Version: 0.3.8
Summary: serialize all of Python
Home-page: https://github.com/uqfoundation/dill
Author: Mike McKerns
Author-email: mmckerns@uqfoundation.org
License: BSD-3-Clause
Location: /home/ml/miniconda3/envs/yolov5/lib/python3.9/site-packages
Requires: 
Required-by:
Only when i try to convert the default models of object detection yolov5 they works fine and even give error but when i installed library still they works but custom model conversion does not work

Code: Select all

(yolov5) ml@ml-ts:~/yolov5$ python export.py --rknpu --weight sdel.pt 
export: data=data/coco128.yaml, weights=['sdel.pt'], imgsz=[640, 640], batch_size=1, device=cpu, half=False, inplace=False, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=['onnx'], rknpu=True
YOLOv5 🚀 v4.0-1657-gd25a075 Python-3.9.12 torch-2.3.1+cu121 CPU

Traceback (most recent call last):
  File "/home/ml/yolov5/export.py", line 723, in <module>
    main(opt)
  File "/home/ml/yolov5/export.py", line 717, in main
    run(**vars(opt))
  File "/home/ml/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/ml/yolov5/export.py", line 533, in run
    model = attempt_load(weights, device=device, inplace=True, fuse=True)  # load FP32 model
  File "/home/ml/yolov5/models/experimental.py", line 80, in attempt_load
    ckpt = torch.load(attempt_download(w), map_location='cpu')  # load
  File "/home/ml/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/serialization.py", line 1025, in load
    return _load(opened_zipfile,
  File "/home/ml/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/serialization.py", line 1446, in _load
    result = unpickler.load()
  File "/home/ml/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/serialization.py", line 1439, in find_class
    return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'dill'

Re: Custem yolov5 model yolov5n - Segmentation fault (core dumped)

Posted: 2024-07-31 2:24
by Crocodile
Hello,Due to the differences in development environments and actual needs, it is challenging to pinpoint the exact issues with custom model inference. In the future, we plan to develop for custom model inference to establish a universal development environment.

Currently, a common issue is the incorrect configuration of the recognition categories and the file describing the categories, coco_80_labels_list.txt.