-
Notifications
You must be signed in to change notification settings - Fork 0
/
orgnizedata.py
44 lines (31 loc) · 1.37 KB
/
orgnizedata.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
32
33
34
35
36
37
38
39
40
import os,glob,pdb
import numpy as np
import pandas as pd
import shutil
# SIXray Dataset. Remove the comment to activate the code for this part
root= '/home/dlp/dataset/SIXray'
split_file_train = os.path.join(root,'ImageSet/10/train.csv')
split_file_test = os.path.join(root,'ImageSet/10/test.csv')
train_data = pd.read_csv(split_file_train, sep=',')
test_data = pd.read_csv(split_file_test, sep=',')
train_file_name = train_data['name'][:]
test_file_name = test_data['name'][:]
for name in train_file_name:
if name[0] in ['P']:
file = os.path.join(root,'positive',name+'.jpg')
target = os.path.join('/home/dlp/github/ganomaly/data/SIXray/train/1.abnormal', name+'.jpg')
else:
file = os.path.join(root, 'negative', name+'.jpg')
target = os.path.join('/home/dlp/github/ganomaly/data/SIXray/train/0.normal', name+'.jpg')
if os.path.exists(file):
shutil.copy(file,target)
#pdb.set_trace()
for name in test_file_name:
if name[0] in ['P']:
file = os.path.join(root, 'positive', name + '.jpg')
target = os.path.join('/home/dlp/github/ganomaly/data/SIXray/test/1.abnormal', name + '.jpg')
else:
file = os.path.join(root, 'negative', name + '.jpg')
target = os.path.join('/home/dlp/github/ganomaly/data/SIXray/test/0.normal', name + '.jpg')
if os.path.exists(file):
shutil.copy(file, target)