bigdataman
commited on
Commit
•
116e812
1
Parent(s):
d12edac
bigdataman
Browse files
README.md
CHANGED
@@ -1,3 +1,57 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
4 |
+
```
|
5 |
+
!pip list
|
6 |
+
!pip install matplotlib
|
7 |
+
!pip install --no-build-isolation scikit-learn
|
8 |
+
!pip install numpy scipy cython
|
9 |
+
!pip install mxnet
|
10 |
+
!pip install opencv-python
|
11 |
+
!pip install numpy==1.23.5
|
12 |
+
!pip install mxnet
|
13 |
+
import mxnet as mx
|
14 |
+
from mxnet import recordio
|
15 |
+
import matplotlib.pyplot as plt
|
16 |
+
import cv2
|
17 |
+
import os
|
18 |
+
|
19 |
+
path_imgidx = 'train.idx' # path to train.rec
|
20 |
+
path_imgrec = 'train.rec' # path to train.idx
|
21 |
+
|
22 |
+
imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r')
|
23 |
+
|
24 |
+
i = 0
|
25 |
+
while True:
|
26 |
+
try:
|
27 |
+
print(i)
|
28 |
+
header, s = recordio.unpack(imgrec.read_idx(i+1))
|
29 |
+
#print(str(header.label))
|
30 |
+
#img = np.array(mx.image.imdecode(s))
|
31 |
+
img = mx.image.imdecode(s).asnumpy()
|
32 |
+
#print(type(img))
|
33 |
+
path = os.path.join('images',str(header.label))
|
34 |
+
if not os.path.exists(path):
|
35 |
+
os.makedirs(path)
|
36 |
+
path = os.path.join(path,str(i))
|
37 |
+
#fig = plt.figure(frameon=False)
|
38 |
+
#fig.set_size_inches(124,124)
|
39 |
+
#ax = plt.Axes(fig, [0., 0., 1., 1.])
|
40 |
+
#ax.set_axis_off()
|
41 |
+
#fig.add_axes(ax)
|
42 |
+
#ax.imshow(img, aspect='auto')
|
43 |
+
#dpi=1
|
44 |
+
#fname= str(i)+'jpg'
|
45 |
+
#fig.savefig(fname, dpi)
|
46 |
+
#plt.savefig(path+'.jpg',bbox_inches='tight',pad_inches=0)
|
47 |
+
(b,g,r)=cv2.split(img)
|
48 |
+
img = cv2.merge([r,g,b])
|
49 |
+
#w,h = img.size
|
50 |
+
#print((img.shape))
|
51 |
+
cv2.imwrite(path+'.jpg',img)
|
52 |
+
i += 1
|
53 |
+
except EOFError:
|
54 |
+
break
|
55 |
+
|
56 |
+
# 1~ 2369931.jpg 17gb
|
57 |
+
```
|