|
--- |
|
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 |
|
``` |