Skip to content

Instantly share code, notes, and snippets.

@ivder
Created July 31, 2019 06:39
Show Gist options
  • Save ivder/569835c9df6f0b466607daf13fb6b35f to your computer and use it in GitHub Desktop.
Save ivder/569835c9df6f0b466607daf13fb6b35f to your computer and use it in GitHub Desktop.
Yolo Format Label to 0 converter
import os
from os import walk, getcwd
input_list = []
for file in os.listdir("/home/ivan/darknet/data/objdamage/"):
input_list.append(file)
for filename in input_list:
content = open("/home/ivan/darknet/data/objdamage/"+filename, "r")
output_path = "/home/ivan/darknet/data/objdamageconverted/"+filename
output_filename = open(output_path, "a")
lines = content.read().splitlines()
for line in lines:
first, rest = line[:1], line[1:]
print first
print rest
output_filename.write("0"+rest+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment