File size: 1,645 Bytes
d12edac
 
54032f1
 
 
 
 
 
d12edac
1934299
 
116e812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
license: mit
language:
- ko
tags:
- asian
- face
- faces
---
Download LINK
https://drive.google.com/drive/folders/1IpR5mRFVFwPfWtcy-HO8Xj2M-TCZKxKK?usp=sharing
```
!pip list
!pip install matplotlib
!pip install --no-build-isolation scikit-learn
!pip install numpy scipy cython
!pip install mxnet
!pip install opencv-python
!pip install numpy==1.23.5
!pip install mxnet
import mxnet as mx
from mxnet import recordio
import matplotlib.pyplot as plt
import cv2
import os

path_imgidx = 'train.idx' # path to train.rec
path_imgrec = 'train.rec' # path to train.idx

imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r')

i = 0
while True:
    try:
        print(i)
        header, s = recordio.unpack(imgrec.read_idx(i+1))
        #print(str(header.label))
        #img = np.array(mx.image.imdecode(s))
        img = mx.image.imdecode(s).asnumpy()
        #print(type(img))
        path = os.path.join('images',str(header.label))
        if not os.path.exists(path):
                os.makedirs(path)
        path = os.path.join(path,str(i))
        #fig = plt.figure(frameon=False)
        #fig.set_size_inches(124,124)
        #ax = plt.Axes(fig, [0., 0., 1., 1.])
        #ax.set_axis_off()
        #fig.add_axes(ax)
        #ax.imshow(img, aspect='auto')
        #dpi=1
        #fname= str(i)+'jpg'
        #fig.savefig(fname, dpi)
        #plt.savefig(path+'.jpg',bbox_inches='tight',pad_inches=0)
        (b,g,r)=cv2.split(img)
        img = cv2.merge([r,g,b])
        #w,h = img.size
        #print((img.shape))
        cv2.imwrite(path+'.jpg',img)
        i += 1
    except EOFError:
        break

# 1~ 2369931.jpg 17gb
```