This repository was archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontagem_label.py
86 lines (69 loc) · 2.71 KB
/
contagem_label.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import time
from pathlib import Path
_DIR_TXT_IMAGEM = "C:\\Users\\IMAGENS_OK"
_CLASSES = "C:\\Users\\IMAGENS_OK\\classes.txt"
DICT_IDS = {}
QTDE_MIN_POR_LABEL = 350
CLASSE_DESIDERAR = 'LIVRE\n'
def verifica_classe_desconsiderar(classe):
ret = False
txt = classe.split('_')
for x in txt:
if x == CLASSE_DESIDERAR:
ret = True
return ret
id = 0
try:
with open(_CLASSES) as f:
for line in f:
DICT_IDS[id] = line, 0
id = id + 1
except Exception as e:
print(line)
print(e)
print ("Falha no processo ler classes.txt")
exit()
###############################################################################################################
#### Inicio da leitura dos arquivos ###########################################################################
###############################################################################################################
ini = time.time()
import os
for root, dirs, files in os.walk(_DIR_TXT_IMAGEM):
for file in files:
if file.endswith(".txt"):
recortes_txt_filename = os.path.join(root, file)
if 'classes.txt' in recortes_txt_filename:
continue
if 'query' in recortes_txt_filename:
continue
try:
with open(recortes_txt_filename) as f:
for line in f:
label_id = int(line[0]+line[1])
lista = list(DICT_IDS[label_id])
lista[1] = lista[1] + 1
DICT_IDS[label_id] = tuple(lista)
except Exception as e:
print(line)
print(recortes_txt_filename)
print(e)
print ("Falha no processo contar label bbox")
print("##################################################")
print('Quantitativos dos recortes')
print("##################################################")
print("")
qtde_total = 0
for x in DICT_IDS:
print(DICT_IDS[x][0], ' --> quantidade: ', DICT_IDS[x][1], '\n\n')
qtde_total += DICT_IDS[x][1]
print("##################################################")
print('Análise de recortes:: Minimo de imagens:: ', QTDE_MIN_POR_LABEL)
print("##################################################")
print("")
for x in DICT_IDS:
if verifica_classe_desconsiderar(DICT_IDS[x][0]):
continue
if DICT_IDS[x][1] < QTDE_MIN_POR_LABEL:
print(DICT_IDS[x][0], ' --> quantidade: ', DICT_IDS[x][1], '\n\n')
print('Quantidade total de recortes :::::::>>>> ', qtde_total)
print('FIM:: Tempo de processamento: ', (time.time() - ini))