学习如何根据自己已有的数据制作数据集!
import os
from PIL import Image
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Flatten ,Dense,Conv1D,MaxPool1D
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import matplotlib.pyplot as plt
x_train_path = './data/class4/FASHION_FC/fashion_image_label/fashion_train_jpg_60000/'
y_train_path = './data/class4/FASHION_FC/fashion_image_label/fashion_train_jpg_60000.txt'
x_test_path = './data/class4/FASHION_FC/fashion_image_label/fashion_test_jpg_10000/'
y_test_path = './data/class4/FASHION_FC/fashion_image_label/fashion_test_jpg_10000.txt'
x_train_savepath = './data/class4/FASHION_FC/fashion_image_label/fashion_x_train.npy'
y_train_savepath = './data/class4/FASHION_FC/fashion_image_label/fashion_y_train.npy'
x_test_savepath = './data/class4/FASHION_FC/fashion_image_label/fashion_x_test.npy'
y_test_savepath = './data/class4/FASHION_FC/fashion_image_label/fashion_y_test.npy'
def generateds(path,txt):
file = open(txt,'r')
lines = file.readlines()
file.close()
x,y_hat = [],[]
for line in lines:
value = line.split()
img_path = path +value[0]
img = Image.open(img_path)
img = np.array(img.convert('L'))
img = img /255.0
x.append(img)
y_hat.append(value[1])
print('loading'+line