Closed ImanHosseini closed 4 years ago
from yolov4.tf import YOLOv4
yolo = YOLOv4()
yolo.classes = "coco.names"
print(len(yolo.classes))
The result should be 80.
It is 80. ("coco.names" is the correct file)
yolov4.weights size is 246 MB (257,717,640 bytes). Is that right?
My bad: The file ("coco.names") is correct, and has 80 lines BUT 'yolo.classes' becomes 159 ! I am running this on windows, and I'm guessing this has to do with line-endings?
Indeed it is, I added a print here:
def read_classes_names(classes_name_path):
names = {}
with open(classes_name_path, "r") as data:
for ID, name in enumerate(data):
print("N:"+name)
names[ID] = name.strip("\n")
return names
And I get:
N:ÿþperson
N:
N:bicycle
N:
...
I changed the environment with Windows and tested it. https://github.com/hhk7734/tensorflow-yolov4/blob/master/test/coco.names file works fine.
This is my file: coco.names (And python version is 3.7.7)
it seems to be an encoding problem.
def read_classes_names(classes_name_path):
names = {}
with open(classes_name_path, "r", encoding="utf-16") as data:
for ID, name in enumerate(data):
names[ID] = name.strip("\n")
return names
This solved it.
However, it does not seem to be a good solution.
Yes! It does help someone who might do the same, but not worth it as you said! Hopefully he googles the error and lands at this issue now :) I had copy+pasted from the raw github file, and the result had weird encoding (2 byte per character, '\x61' -> '\x61\x00') Thank You.
I installed yolov4 from PyPI, and attempting to run the 1st example I get "Model and weights file do not match" [I am using "yolov4.weights" file from the link in the description]