Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
📝 Update: labelme to YOLOv5
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerohertz committed Apr 4, 2023
1 parent 62f0dc1 commit 9d132ee
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions labelme2YOLOv5.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ def labelme2YOLOv5(target, relJson):
with open(relJson) as f:
data = json.load(f)
for i in range(len(data['shapes'])):
tmp = data['shapes'][i]['points']
tmp = data['shapes'][i]['points']
tar = []
cnt = 0
for j in tmp:
for k in j:
if cnt % 2 == 0:
tar.append(k/w)
else:
tar.append(k/h)
tar.append(j[0]/w)
tar.append(j[1]/h)
with open(targetDirLab + '/' + relJson.replace('.json', '.txt'), 'a', encoding='utf-8') as f:
wr = csv.writer(f, delimiter=' ')
wr.writerow([0, *tar])
Expand All @@ -68,6 +65,7 @@ def labelme2YOLOv5(target, relJson):
for c in tqdm(candidate):
if cnt % 3 == 0:
labelme2YOLOv5('val', c)
labelme2YOLOv5('train', c)
else:
labelme2YOLOv5('train', c)
cnt += 1
Expand Down

0 comments on commit 9d132ee

Please sign in to comment.