Skip to content

Commit 84f206b

Browse files
committed
Updated path handling for yolo .names and .data files -resolves #5
1 parent 710e830 commit 84f206b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

YOLOader.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ def create_data(self):
6969

7070
print("Created new .data file for the loaded network.")
7171

72+
73+
def update_data(self):
74+
"""
75+
creates a .data file in the location of the config file with the current location of the .names file and sets
76+
the path to the output file as the new .data file.
77+
"""
78+
with open(self.data, "r") as f:
79+
lines = f.readlines()
80+
for l, line in enumerate(lines):
81+
if line.split(" ")[0] == "names":
82+
lines[l] = "names = " + str(self.names).replace("\\", "/") + "\n"
83+
84+
with open(self.data, "w") as f:
85+
for line in lines:
86+
f.write(line)
87+
88+
print("INFO: Updated .data file for the loaded network to include absolute path of .names file")
89+
7290
def update_cfg(self, nw_width, nw_height, encoding="utf-8"):
7391
"""
7492
Updates the cfg file and creates a copy of it in the same directory as the original. The function updates the

__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"author": "Fabian Plum",
3131
"description": "Deep learning-based multi animal tracker",
3232
"blender": (3, 3, 0),
33-
"version": (0, 2, 2),
33+
"version": (0, 2, 3),
3434
"location": "",
3535
"warning": "RUN IN ADMINISTRATOR MODE DURING INSTALLATION!",
3636
"category": "motion capture"
@@ -262,6 +262,9 @@ def execute(self, context):
262262

263263
if yolo_paths.data is None:
264264
yolo_paths.create_data()
265+
else:
266+
# update the data file to ensure it points to the correct absolute location of the names file
267+
yolo_paths.update_data()
265268

266269
context.scene.detection_config_path = yolo_paths.cfg
267270
context.scene.detection_data_path = yolo_paths.data

0 commit comments

Comments
 (0)