[4f54f1]: / data_collector.py

Download this file

27 lines (20 with data), 926 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
import os
import config
import fetch_data.data_client as client
def should_download_images(configured_path, required_count):
if not os.path.exists(configured_path):
return True
files_count = len([name for name in os.listdir(configured_path)
if os.path.isfile(os.path.join(configured_path, name))])
print("Number of existing images is {}.".format(files_count))
return files_count < required_count
if __name__ == '__main__':
if should_download_images(config.SEGMENTED_LUNGS_DIR,
config.REQUIRED_IMGS_COUNT):
client.collect_images(config.BUCKET_IN_USE,
config.PROJECT_NAME,
config.FETCHED_DATA_DIR)
else:
print("Images required for trainig the selected",
"model have already been downloaded to: ",
config.SEGMENTED_LUNGS_DIR)