RuntimeError: Unable to load the engine file- YOLOV4-Tiny Custom Weights
See original GitHub issueI am trying to convert custom weights from **yolov4-tiny model**
. When I try and build an engine I am getting following error. The YOLO anchors are also setup correctly. Can anyone help me with this ? @GeekAlexis
root@1bf3cb8ffb41:~/FastMOT# python3 app.py --input_uri mid1.mp4 --mot -g
[ WARN:0] global /usr/src/app/OpenCV/modules/videoio/src/cap_gstreamer.cpp (896) open OpenCV | GStreamer warning: unable to query duration of stream
[ WARN:0] global /usr/src/app/OpenCV/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=0, duration=-1
2021-07-15 12:23:48 [ INFO] 1280x720 stream @ 30 FPS
2021-07-15 12:23:48 [ INFO] Loading detector model...
2021-07-15 12:23:49 [ INFO] Building engine with batch size: 1
2021-07-15 12:23:49 [ INFO] This may take a while...
[TensorRT] ERROR: ../rtSafe/safeRuntime.cpp (25) - Cuda Error in allocate: 2 (out of memory)
[TensorRT] ERROR: ../rtSafe/safeRuntime.cpp (25) - Cuda Error in allocate: 2 (out of memory)
2021-07-15 12:23:51 [CRITICAL] Failed to build engine
Traceback (most recent call last):
File "app.py", line 98, in <module>
main()
File "app.py", line 50, in main
mot = fastmot.MOT(config['resize_to'], config['mot'], draw=draw, verbose=args.verbose)
File "/usr/src/app/FastMOT/fastmot/mot.py", line 55, in __init__
self.detector = YOLODetector(self.size, config['yolo_detector'])
File "/usr/src/app/FastMOT/fastmot/detector.py", line 187, in __init__
self.backend = InferenceBackend(self.model, 1)
File "/usr/src/app/FastMOT/fastmot/utils/inference.py", line 44, in __init__
raise RuntimeError('Unable to load the engine file')
RuntimeError: Unable to load the engine file
YOLOV4-Tiny ANCHORS - yolo.py
class YOLOv4(YOLO):
ENGINE_PATH = Path(__file__).parent / 'yolov4-tiny.trt' #'yolov4_crowdhuman.trt'
MODEL_PATH = Path(__file__).parent / 'yolov4-tiny.onnx' #'yolov4_crowdhuman.onnx'
NUM_CLASSES = 12
INPUT_SHAPE = (3, 416, 416)
LAYER_FACTORS = [32, 16]
SCALES = [1.05, 1.05]
ANCHORS = [[10, 14, 23, 27, 37, 58],
[81, 82, 135, 169, 344, 319]]
#ANCHORS = [[81, 82, 135, 169, 344, 319],
# [23, 27, 37, 58, 81, 82]]
Classes
12
yolo.cfg
[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=64
subdivisions=1
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.00261
burn_in=1000
max_batches = 24000
policy=steps
steps=19200,21600
scales=.1,.1
[convolutional]
batch_normalize=1
filters=32
size=3
stride=2
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky
[route]
layers=-1
groups=2
group_id=1
[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky
[route]
layers = -1,-2
[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky
[route]
layers = -6,-1
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky
[route]
layers=-1
groups=2
group_id=1
[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky
[route]
layers = -1,-2
[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky
[route]
layers = -6,-1
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky
[route]
layers=-1
groups=2
group_id=1
[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky
[route]
layers = -1,-2
[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky
[route]
layers = -6,-1
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky
##################################
[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky
[convolutional]
size=1
stride=1
pad=1
filters=51
activation=linear
[yolo]
mask = 3,4,5
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
classes=12
num=6
jitter=.3
scale_x_y = 1.05
cls_normalizer=1.0
iou_normalizer=0.07
iou_loss=ciou
ignore_thresh = .7
truth_thresh = 1
random=0
resize=1.5
nms_kind=greedynms
beta_nms=0.6
[route]
layers = -4
[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky
[upsample]
stride=2
[route]
layers = -1, 23
[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky
[convolutional]
size=1
stride=1
pad=1
filters=51
activation=linear
[yolo]
mask = 0,1,2
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
classes=12
num=6
jitter=.3
scale_x_y = 1.05
cls_normalizer=1.0
iou_normalizer=0.07
iou_loss=ciou
ignore_thresh = .7
truth_thresh = 1
random=0
resize=1.5
nms_kind=greedynms
beta_nms=0.6
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
RuntimeError: Unable to load the engine file #39 - GitHub
[INFO] 1920x1080 stream @ 29 FPS [INFO] Loading detector model... /home/videocon/work/FastMOT-master/fastmot/models/yolov4_crowdhuman.trt ...
Read more >Getting Runtime error while making API using YOLOV4-Pytorch
RuntimeError : shape '[256, 384, 3, 3]' is invalid for input of size 767781. Using yolov4-tiny with pretrained weights. yolo.py file
Read more >Train a custom YOLOv4-tiny object detector on Linux - Medium
In this tutorial, we will be training a custom object detector for mask detection using YOLOv4-tiny and Darknet on our Linux(Ubuntu 18.04) system ......
Read more >Error in Yolov4 engine conversion, - TAO Toolkit
I am getting following error during generation of Yolo engine through ... [UID = 1]: build engine file failed Bus error (core dumped)....
Read more >Solved: Re: Help converting owned YOLOv4-tiny model to IR
Is there a command to preconvert a custom YoloV4-tiny model before running ... Detection API: None - Use the config file: None -...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks like you changed the default anchor mask from darknet, so they should be as follows:
Yes I did check the output of this model in darknet and it’s working very well.
https://user-images.githubusercontent.com/72124771/126612486-bbf3189c-a4ff-4a3c-8230-820e54fac076.mp4
I used tensorrt_demos to convert it into ONNX .