hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

"Model and weights file do not match" when using custom weights file from darknet #21

Closed victoriest closed 4 years ago

victoriest commented 4 years ago

im trained a weights file by darknet yolov4-tiny, there are 3 classes in my custom dataset, so my .cfg file for darknet:

[net]
# Testing
#batch=1
#subdivisions=1
# Training
batch=32
subdivisions=16
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=100
max_batches = 18000
policy=steps
steps=14400,16200
scales=.1,.1

...

[convolutional]
size=1
stride=1
pad=1
filters=24
activation=linear

[yolo]
mask = 3,4,5
anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
classes=3
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

...

[convolutional]
size=1
stride=1
pad=1
filters=24
activation=linear

[yolo]
mask = 0,1,2
anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
classes=3
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

the error occur when

from yolov4.tf import YOLOv4

yolo = YOLOv4(tiny=True)

yolo.classes = "tftf.names"

yolo.make_model()
yolo.model.summary()

yolo.load_weights("yolov4-tiny-tftf_best.weights", weights_type="yolo")
hhk7734 commented 4 years ago

Hi~

Can you share tftf.names and yolov4-tiny-tftf_best.weights?

victoriest commented 4 years ago

thanks for the reply. tftf.names only has 3 lines:

1
2
3

yolov4-tiny-tftf_best.zip

hhk7734 commented 4 years ago

yolov4-tiny weights file size for 3 classes is 22.4MB. But your weights file size is 21.3MB.

victoriest commented 4 years ago

yolov4-tiny weights file size for 3 classes is 22.4MB. But your weights file size is 21.3MB.

it seem someting wrong with the zip file. the size of weights file is 22360148 bytes in my local machine.

and i am checked the cfg file with no incorrection.

im tring to re-train the model with yolov4(not tiny)

hhk7734 commented 4 years ago

yolov4-tiny weights file size for 3 classes is 23,539,796 bytes.

andreyshilenko99 commented 4 years ago

Hallo. Got problems working with your Yolov4 network. Im trying to detect only persons inside my videostream, but my GPU power is not enought to do it in realtime. SO i decided to remove some classes from coco.names (actually all classes instead of person) and i got an error, trying to launch my code. As I understood from messages above I also need to edit yolov4.weights file, but I got no idea how to do this, because weights file cant be opened by text editors. Can u help me please?? Maybe u can upload a weights.file, which contains only person class. Thank u a lot! u are doing a great job

hhk7734 commented 4 years ago

I think that it can be possible to extract some kernel, but, It is difficult to help because it seems to takes a lot of time. I think it would be faster to create and train a human dataset using the coco dataset.