Fashion image generator website

Fashion Image Generator Website

Fashion Image Generator Website

Video Demo:

https://youtu.be/czrE6WhSQfc?si=Mpr7etCpIWHDSWiP

Description:

Train ML models with tensorflow and Host them on website with Flask.
To save your model you can simply run:

generator.save("YOURMODELNAME.hd5")
  • You can change the image data set and increase the epoch from 10 to 50 in the notebook provided.
    train_dcgan(gan, dataset, batch_size, num_features, epochs=50)
  • You can deepen the model structure as well to have a much better results.
    generator = keras.models.Sequential([
        keras.layers.Dense(7 * 7 * 128, input_shape=[num_features]),
        keras.layers.Reshape([7, 7, 128]),
        keras.layers.BatchNormalization(),
        keras.layers.Conv2DTranspose(64, (5,5), (2,2), padding="same", activation="selu"),
        keras.layers.BatchNormalization(),
        keras.layers.Conv2DTranspose(1, (5,5), (2,2), padding="same", activation="tanh"),
    ])

The model is hosted using FLASK and you can generate images. The input to the images are gaussian noises. You can change the gaussian noises and give them as an input to the user to generate them or you can change your input for image to anything else. There are a lot of possibilities to extend upon.

The output of the generated images are represented as a 4D tensor, with the shape (1, 28, 28, 1), which is common for grayscale images of size 28x28 pixels.

The values in the tensor represent pixel intensities, ranging from -1 to 1. The generated images are displayed in a grid, with each row containing a different image. Each pixel's value is a floating-point number indicating the grayscale intensity, where -1 corresponds to black, 1 corresponds to white, and values in between represent shades of gray.

Normalize the images from [-1, 1] to [0, 255] as in notebook visualization
generated_images = ((generated_images + 1) / 2 * 255).numpy().astype(np.uint8)

generated_images_base64 = []
for img in generated_images:
    buffered = io.BytesIO()
    Image.fromarray(img.reshape(28, 28), 'L').save(buffered, format="PNG")
    img_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')
    generated_images_base64.append(img_base64)

Kaggle Link

https://www.kaggle.com/code/codewithpiri/adversarial-networks-dcgan-fashion-image-generator

You can download the utilities needed from my kaggle account:
https://www.kaggle.com/codewithpiri/datasets

Feel free to contact me for more details:
farhad.piri@ee.sharif.edu

Leave a Reply

Your email address will not be published. Required fields are marked *