Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello,
I want reproduce the tricks in chapter "Data pre-processing and data augmentation" from this website https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html
And I have problem to execute python script with ImageDataGenerator.
# -*- coding: utf-8 -*-
import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
# Read recipe inputs
train_apple = dataiku.Folder("l8PGPsC0")
train_apple_info = train_apple.get_info()
datagen = ImageDataGenerator(
rotation_range=40,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest')
# img = load_img('data/train/cats/cat.0.jpg') # this is a PIL image
img = dataiku.Folder("l8PGPsC0") # this is a PIL image
x = img_to_array(img) # this is a Numpy array with shape (3, 150, 150)
x = x.reshape((1,) + x.shape) # this is a Numpy array with shape (1, 3, 150, 150)
# the .flow() command below generates batches of randomly transformed images
# and saves the results to the `preview/` directory
i = 0
for batch in datagen.flow(x, batch_size=1,
save_to_dir=dataiku.Folder("n6fptvg8"), save_prefix='cat', save_format='jpeg'):
i += 1
if i > 2: #nb picture generated
break # otherwise the generator would loop indefinitely
# Write recipe outputs
train_apple_mod = dataiku.Folder("n6fptvg8")
train_apple_mod_info = train_apple_mod.get_info()
Hi @Ignacio_Toledo ,
I have posted like a noob, shame on me.
This script is for use ImageDataGenerator.
But I can do that by this way
Perhaps I do ask to a moderator to delete this post.
Hi @BenGonGon. What is exactly the problem you have? Any error messages? Or you don't know where to run this code?
Hi @Ignacio_Toledo ,
I have posted like a noob, shame on me.
This script is for use ImageDataGenerator.
But I can do that by this way
Perhaps I do ask to a moderator to delete this post.
No worries @BenGonGon! We can all make mistakes!