-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsegment_dataset.py
More file actions
25 lines (17 loc) · 1005 Bytes
/
Copy pathsegment_dataset.py
File metadata and controls
25 lines (17 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
def run_segment(path_to_bucket, output_dir_path, start, end, colab_num, log_error_folder_path):
error_file_path = os.path.join(log_error_folder_path, str(colab_num) + 'error_file.txt')
indicator_file_name = 'indicator_file_dir/segmentation/' + str(colab_num)+'_seg_indicator_file.txt'
indicator_file= os.path.join(path_to_bucket, indicator_file_name)
try:
with open(indicator_file, 'r') as ind_file:
start = int(ind_file.read()) + 1
except Exception as ex:
print(ex)
print("This exception happens because the indication file is initialized")
for i in range(start, end+ 1):
name_file = 'image_name_files_dir/file_path_list_' + str(i) + '.txt'
file_list_path = os.path.join(path_to_bucket, name_file)
!python3 u2net_test.py --input {file_list_path} --output_dir {output_dir_path} --errorFile {error_file_path}
with open(indicator_file, 'w') as ind_file:
ind_file.write(str(i))