Skip to content

Instantly share code, notes, and snippets.

@THEFASHIONGEEK
Last active February 18, 2020 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save THEFASHIONGEEK/788bdfdc0cbbf0b2039956aedb679c39 to your computer and use it in GitHub Desktop.
Save THEFASHIONGEEK/788bdfdc0cbbf0b2039956aedb679c39 to your computer and use it in GitHub Desktop.
combined = []
for i in tqdm(range(len(folders))):
files = os.listdir(anno_dir + "/" + folders[i])
for j in range(len(files)):
fname = anno_dir + "/" + folders[i] + "/" + files[j]
f = open(fname, 'r')
lines = f.readlines()
f.close()
anno = [folders[i] + "/" + ".".join(files[j].split(".")[:-1])]
wr = ""
for k in range(1, len(lines)):
tmp = lines[k].split(" ")
label = folders[i]
x1 = int(tmp[1])
y1 = int(tmp[2])
x2 = x1 + int(tmp[3])
y2 = y1 + int(tmp[4])
wr += str(x1) + " " + str(y1) + " " + str(x2) + " " + str(y2) + " " + label + " "
wr = wr[:-1]
if(wr != ""):
anno.append(wr)
combined.append(anno)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment