Skip to content

Instantly share code, notes, and snippets.

@Krucamper
Created November 23, 2019 17:54
Show Gist options
  • Save Krucamper/bf9cd2485fec896fe3e7793ca593d7f3 to your computer and use it in GitHub Desktop.
Save Krucamper/bf9cd2485fec896fe3e7793ca593d7f3 to your computer and use it in GitHub Desktop.
CNN กับ Marvel Cinematic Universe (img genarate)
import os
from PIL import Image
raw_image = './raw'
prepro_image = './genarate'
classes = {'BlackPanther', 'DoctorStrange', 'IronMan', 'ScarletWitch', 'SpiderMan', 'Thor'}
def genarate_image():
for index, name in enumerate(classes):
class_path = raw_image + "/" + name + "/"
path_image = prepro_image +"/" + name +"/"
for image_name in os.listdir(class_path):
img_path = class_path + image_name
img = Image.open(img_path)
img = img.resize((64, 64))
if img.mode != 'RGB':
img = img.convert('RGB')
if not os.path.exists(path_image):
os.makedirs(path_image)
img.save(path_image + "/" + image_name)
genarate_image()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment