-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.py
More file actions
49 lines (41 loc) · 937 Bytes
/
eval.py
File metadata and controls
49 lines (41 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import pymongo
import cv2
import sys
import csv
if(len(sys.argv) < 2):
print("Usage: python3 eval.py labels_file > outputfile")
sys.exit()
# get image name and label from file
f = open(sys.argv[1], "r")
lines = f.readlines()
#f = open("ids_num.txt", "r")
#nums = f.readlines()
#numMap = {}
#for num in nums:
#print(num)
#tmpid = num.split(' ')[0]
#tmpnum = num.split(' ')[1].replace("\n", "")
#numMap[tmpid] = tmpnum
#print(numMap)
labels = {}
for line in lines:
print(line)
idNum = line.split('_')[0]
#print(idNum, end=" ")
label = line.split(' ')[-1]
label = label.replace('\n', '')
#print(label)
if label in labels:
labels[label].append(idNum)
else:
labels[label] = [idNum]
for label in labels:
print(label, end=" ")
print(len(labels[label]))
seen = []
for num in labels[label]:
if not num in seen:
seen.append(num)
print("\t", num, end=" ")
print(labels[label].count(num))