DeepSMOTE
DeepSMOTE copied to clipboard
How to convert
The final generated TXT file, MNIST data set is a picture data set, may I ask how to convert the generated file into a picture?
you can use this code to convert the txt to pictures into folds :
'''
import matplotlib.pyplot as plt
from PIL import Image
pic_x = np.loadtxt('G:/the experiment of autumn school/NLP/output0_trn_img3.txt')
pic_y = np.loadtxt('G:/the experiment of autumn school/NLP/output0_trn_lab3.txt')
show_index_image = []
show_index_label = []
show_index_image2 = []
try: os.mkdir("./output") except: print("already exist") for i in range(10): path ="./output/"+str(i) os.mkdir(path)
for i in range(len(pic_x)): show_index_image.append(np.array(pic_x[i].reshape(28,28))) show_index_label.append(pic_y[i]) temp_img = pic_x[i] show_index_image2.append(temp_img)
for i in range(len(show_index_label)):
for k in show_index_image[i]:
for j in range(len(k)):
if k[j]<=0:
k[j]=0
else:
k[j]=255
patha = './output/'+str(int(show_index_label[i]))+'/'+str(i)+'.png'
# save the picture
cv2.imwrite(patha, show_index_image[i])
'''