From ad428c6a7d50807de0023320459893fb318fa9da Mon Sep 17 00:00:00 2001 From: rahonix <44674265+rahonix@users.noreply.github.com> Date: Mon, 16 May 2022 14:23:25 +0200 Subject: [PATCH] Update yolo_io.py Use default predefined_classes.txt if folder contains no classes.txt. --- libs/yolo_io.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/yolo_io.py b/libs/yolo_io.py index 192e2c785..0dadd5c9c 100644 --- a/libs/yolo_io.py +++ b/libs/yolo_io.py @@ -94,7 +94,11 @@ def __init__(self, file_path, image, class_list_path=None): # print (file_path, self.class_list_path) - classes_file = open(self.class_list_path, 'r') + try: + classes_file = open(self.class_list_path, 'r') + except FileNotFoundError: + classes_file = open(os.path.join(os.path.dirname(__file__), "..", "data", "predefined_classes.txt"), 'r') + self.classes = classes_file.read().strip('\n').split('\n') # print (self.classes)