-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask1.py
More file actions
19 lines (14 loc) · 832 Bytes
/
task1.py
File metadata and controls
19 lines (14 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
import csv
def create_annotation(class_name: str, annotation_name: str) -> None:
"""This function creates a cvs file with three parameters: the absolute path to the file, the relative path to the
file and the class label"""
path_class = os.path.join('dataset', class_name)
names_class = os.listdir(path_class)
with open(annotation_name, mode="w", encoding="UTF-16", newline='') as file:
file_write = csv.writer(file, delimiter=',')
file_write.writerow(['The absolute path to the file', 'The relative path to the file', 'The class label'])
for name in names_class:
file_write.writerow([os.path.abspath(name), os.path.join(path_class, name), class_name])
def run1(class_name: str, annotation_name: str) -> None:
create_annotation(class_name, annotation_name)