forked from fcdl94/FSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_isic.py
28 lines (22 loc) · 918 Bytes
/
utils_isic.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
import os
def elenca_immagini(directory):
elenco_immagini = []
# Controlla tutti i file nella directory
for filename in os.listdir(directory):
# Verifica se il file è un'immagine
if filename.endswith(".jpg") or filename.endswith(".jpeg") or filename.endswith(".png") or filename.endswith(".gif"):
elenco_immagini.append(filename)
return elenco_immagini
def salva_su_file(nomi_immagini, output_file):
with open(output_file, "w") as file:
for nome in nomi_immagini:
file.write(nome + "\n")
if __name__ == "__main__":
# Directory delle immagini
directory_immagini = "data/isic_tiny/images/val2017"
# Ottieni elenco delle immagini
nomi_immagini = elenca_immagini(directory_immagini)
# Nome del file di output
file_output = "val.txt"
# Salva l'elenco delle immagini su file
salva_su_file(nomi_immagini, file_output)