Skip to content

Commit ce99c2e

Browse files
committed
Fix label misnaming
1 parent fb6d628 commit ce99c2e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

label_studio_ml/examples/yolov8/model.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(self, project_id, **kwargs):
8181
self.custom_name_to_num = {v:k for k, v in self.custom_num_to_name.items()}
8282

8383

84+
8485
def predict(self, tasks: List[Dict], context: Optional[Dict] = None, **kwargs) -> List[Dict]:
8586
""" Inference logic for YOLO model """
8687

@@ -224,14 +225,16 @@ def fit(self, event, data, **kwargs):
224225
project_path = sample_img_path.split("/")[:-1]
225226
image_name = sample_img_path.split("/")[-1]
226227

228+
229+
227230
img1 = img.save(f"./datasets/temp/images/{image_name}")
228231
img2 = img.save(f"./datasets/temp/images/(2){image_name}")
229232

230233
all_new_paths.append(f"./datasets/temp/images/{image_name}")
231234
all_new_paths.append(f"./datasets/temp/images/(2){image_name}")
232235

233236
# now saving text file labels
234-
txt_name = (image_path.split('/')[-1]).rsplit('.', 1)[0]
237+
txt_name = image_name.rsplit('.', 1)[0]
235238

236239
with open(f'./datasets/temp/labels/{txt_name}.txt', 'w') as f:
237240
f.write("")
@@ -246,7 +249,7 @@ def fit(self, event, data, **kwargs):
246249

247250
value = result['value']
248251
label = value['rectanglelabels'][0]
249-
252+
250253
if label in self.custom_name_to_num:
251254

252255
# these are out of 100, so you need to convert them back
@@ -263,7 +266,7 @@ def fit(self, event, data, **kwargs):
263266
trans_x = (x / 100) + (0.5 * w)
264267
trans_y = (y / 100) + (0.5 * h)
265268

266-
# now getting the class label
269+
# now getting the class label
267270
label_num = self.custom_name_to_num.get(label)
268271

269272
with open(f'./datasets/temp/labels/{txt_name}.txt', 'a') as f:

0 commit comments

Comments
 (0)