ChenYingpeng / darknet2caffe

Convert darknet weights to caffemodel
183 stars 88 forks source link

KeyError: 'type' #23

Open lccui opened 3 years ago

lccui commented 3 years ago

yolov4: mish to relu

('upsample:', 119) ('upsample:', 129) unknow layer type yolo unknow layer type yolo unknow layer type yolo Traceback (most recent call last): File "darknet2caffe.py", line 519, in darknet2caffe(cfgfile, weightfile, protofile, caffemodel) File "darknet2caffe.py", line 15, in darknet2caffe save_prototxt(net_info , protofile, region=False) File "/home/lab/soft/darknet2caffe/prototxt.py", line 173, in save_prototxt if layer['type'] != 'Region' or region == True: KeyError: 'type'

lccui commented 3 years ago

yolov4: mish to leaky is ok. I0825 16:46:47.052114 9499 net.cpp:257] Network initialization done. unknow layer type yolo unknow layer type yolo save prototxt to prototxt/yolov4-leaky-test.prototxt save caffemodel to caffemodel/yolov4-leaky-test.caffemodel

lccui commented 3 years ago

Do you know the reasons why when I run nnie mapper ./yolov4.cfg,the result is begin net parsing.... end net parsing begin prev optimizing.... Segmentation fault (core dumped)

sakethkhandavalli commented 3 years ago

@@ File "darknet2caffe.py", line 519, in darknet2caffe(cfgfile, weightfile, protofile, caffemodel) File "darknet2caffe.py", line 15, in darknet2caffe save_prototxt(net_info , protofile, region=False) File "/home/darknet2caffe/prototxt.py", line 173, in save_prototxt if layer['type'] != 'Region' or region == True: KeyError: 'type'

I too am getting the above error while running the code, does anyone know how to fix this and get the caffe model correctly. @ChenYingpeng @becauseofAI

northeastsquare commented 3 years ago

用python3 的话生成的protoxt文件为空,要修改里面的print为fp.write()

ikuokuo commented 2 years ago

Edit darknet2caffe.py line 233, add activation relu:

if block['activation'] == 'relu':
    activate_layer['type'] = 'ReLU'
    relu_param = OrderedDict()
    relu_param['negative_slope'] = '0'
    activate_layer['relu_param'] = relu_param
elif block['activation'] == 'leaky':
    activate_layer['type'] = 'ReLU'
    relu_param = OrderedDict()
    relu_param['negative_slope'] = '0.1'
    activate_layer['relu_param'] = relu_param
elif block['activation'] == 'mish':
    activate_layer['type'] = 'Mish'
    activate_layer['name'] = 'layer%d-act-mish' % layer_id

yolov4: mish to relu

('upsample:', 119) ('upsample:', 129) unknow layer type yolo unknow layer type yolo unknow layer type yolo Traceback (most recent call last): File "darknet2caffe.py", line 519, in darknet2caffe(cfgfile, weightfile, protofile, caffemodel) File "darknet2caffe.py", line 15, in darknet2caffe save_prototxt(net_info , protofile, region=False) File "/home/lab/soft/darknet2caffe/prototxt.py", line 173, in save_prototxt if layer['type'] != 'Region' or region == True: KeyError: 'type'