-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_image_data.py
More file actions
41 lines (35 loc) · 1015 Bytes
/
create_image_data.py
File metadata and controls
41 lines (35 loc) · 1015 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#create_image_data.py
///////////////////////////////////////////
N,C,D,H,W = 60,3,10,100,100
paths=[]
for i in range(600):
r=i//10
c=i%10
datai = torch.randint(low=0, high=256, size=(3,100,100), dtype=torch.uint8)
path='./data/'+str(r).zfill(3)+'_'+str(c).zfill(3)+'.pt'
paths+=[path]
torch.save(datai,path)
label = [0,1,2]
label = np.random.randint(0,3,size=(60,))
labels = pd.DataFrame(columns=['id','label'])
labels['id']=list(range(60))
labels['label']=label
labels.to_csv('labels.csv',index=False)
///////////////////////////////////////////
!mkdir train
!mkdir test
labels = ['a','b','c']
for L in labels:
!mkdir train/{L}
!mkdir test/{L}
dirs=['train','test']
N,C,H,W = 400,3,100,100
paths=[]
for i in range(400):
k=i//300
p=i%3
datai = torch.randint(low=0, high=256, size=(3,100,100), dtype=torch.uint8)
path=f'./{dirs[k]}/{labels[p]}/'+str(i).zfill(3)+'.pt'
paths+=[path]
torch.save(datai,path)
///////////////////////////////////////////