-
Notifications
You must be signed in to change notification settings - Fork 1
/
csv_generator.py
31 lines (29 loc) · 873 Bytes
/
csv_generator.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
"""
Automated Dispersion Compensation Network (ADC-Net).
This file is to generate a .csv file based on the target directory.
For the implementation ADC-Net, all files have the same name.
For example, image001.tiff will be the name for the first image in magnitude 1, magnitude 2, magnitude 3, ..., and compensated folders.
@author: dleninja
"""
#
import pandas as pd
from pathlib import Path
#
image_names = []
#
basepath =Path("dataset_dir/magnitude1")
files_in_basepath = basepath.iterdir()
#
for item in files_in_basepath:
if item.is_file():
image_names.append(item.name)
#
dictionary = {'image_names': image_names}
dataframe = pd.DataFrame(dictionary)
#
n_length = int(len(dataframe)*0.7)
dataframe_train = dataframe[:n_length]
dataframe_test = dataframe[n_length:]
#
dataframe_train.to_csv("train.csv", index=False)
dataframe_test.to_csv("test.csv", index=False)