Data Science Asked by kali_xyyali on April 21, 2021
I’m trying to make GAN which will generate art from random noise. I rely on this article https://towardsdatascience.com/generating-modern-arts-using-generative-adversarial-network-gan-on-spell-39f67f83c7b4
First off i’ve created training_data.npy file. For this purpose i wrote simple script.
import os
import numpy as np
from PIL import Image
import sys
args = sys.argv
del args[0]
if not args:
print('Add at least 1 dir')
sys.exit(0)
for i in args:
if i not in os.listdir(os.getcwd()):
print(f"Can't find {i} here")
sys.exit()
IMAGE_SIZE = 128
IMAGE_CHANNELS = 3
training_data = []
print('resizing...')
for dir in args:
for filename in os.listdir(os.path.abspath(dir)):
path = os.path.join(os.getcwd(), dir, filename)
image = Image.open(path).resize((IMAGE_SIZE, IMAGE_SIZE), Image.ANTIALIAS)
training_data.append(np.asarray(image))
training_data = np.reshape(
training_data, (-1, IMAGE_SIZE, IMAGE_SIZE, IMAGE_CHANNELS))
training_data = training_data / 127.5 - 1
print('saving file...')
def get_name():
i = 1
while True:
if f'training_data_{i}.npy' in os.getcwd():
i += 1
continue
return f'training_data_{i}.npy'
name = get_name()
print(f'saving to file {name}')
np.save(name, training_data)
There are folders(which contain images) in my current directory
After that i wrote code bellow for training model(this code locate in google colab, training_data.npy i also uploaded to google drive and use it in google colab)
https://colab.research.google.com/drive/1pLDdyRwQQe1SqYNUI8pwzgnOeUGrxnR6?usp=sharing
If u click on link above, u’ll see my error which i got. Please, help me to resolve it.
Thank u.
P.S
5 days ago i read this article carefully , and understood it. But now i’ve decided to just copy and paste the code from article and don’t reread it again. Forgive me if i make some errors in the code.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP