-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import json | ||
import os | ||
|
||
delete_files_path = 'data/huawei_data/delete_bak' | ||
dataset_split_file = 'data/huawei_data/dataset_split.json' | ||
|
||
delete_files = [f for f in os.listdir(delete_files_path) if f.endswith('jpg')] | ||
with open(dataset_split_file, 'r') as f: | ||
train_list, val_list = json.load(f) | ||
|
||
delete_files_count = [] | ||
undelete_train_list = [] | ||
for fold_index, fold_list in enumerate(train_list): | ||
fold_sample_list = fold_list[0] | ||
fold_label_list = fold_list[1] | ||
undelete_fold_sample = [] | ||
undelete_fold_label = [] | ||
for sample_index, sample in enumerate(fold_sample_list): | ||
if sample not in delete_files: | ||
# 不在被删除的文件中 | ||
undelete_fold_sample.append(sample) | ||
undelete_fold_label.append(fold_label_list[sample_index]) | ||
else: | ||
delete_files_count.append([sample, fold_label_list[sample_index]]) | ||
print('[Train Fold %d] Remove: %s, Label: %d' % (fold_index, sample, fold_label_list[sample_index])) | ||
undelete_train_list.append([undelete_fold_sample, undelete_fold_label]) | ||
|
||
undelete_val_list = [] | ||
for fold_index, fold_list in enumerate(val_list): | ||
fold_sample_list = fold_list[0] | ||
fold_label_list = fold_list[1] | ||
undelete_fold_sample = [] | ||
undelete_fold_label = [] | ||
for sample_index, sample in enumerate(fold_sample_list): | ||
if sample not in delete_files: | ||
# 不在被删除的文件中 | ||
undelete_fold_sample.append(sample) | ||
undelete_fold_label.append(fold_label_list[sample_index]) | ||
else: | ||
delete_files_count.append([sample, fold_label_list[sample_index]]) | ||
print('[Val Fold %d] Remove: %s, Label: %d' % (fold_index, sample, fold_label_list[sample_index])) | ||
undelete_val_list.append([undelete_fold_sample, undelete_fold_label]) | ||
|
||
with open('dataset_split_delete.json', 'w') as f: | ||
json.dump([undelete_train_list, undelete_val_list], f, ensure_ascii=False) |