Exemplo n.º 1
0
def simpple_image_data_generator(batch_size, imagepaths, classes):
    class_indices = dict(zip(classes, range(len(classes))))
    while True:
        for start in np.arange(0, len(imagepaths), batch_size):
            x_batch = []
            y_batch = []
            end = min(start + batch_size, len(imagepaths))
            train_batch = imagepaths[start:end]
            for imagepath in train_batch:
                img = pil_image.imread(imagepath)
                class_name = os.path.basename(os.path.dirname(imagepaths[i]))
                
                x_batch.append(img)
                y_batch.append(class_indices[class_name])
            x_batch = np.array(x_batch, np.float32) / 255.
            y_batch = np.array(y_batch, np.uint8)
            yield x_batch, y_batch
Exemplo n.º 2
0
import PIL
import numpy as np

img_path = 'data/images_train/data/123033/0e27621e3f8b484c993619abd064948be27f60a2.jpg'
img = PIL.imread(img_path)
img_array = np.asarray(img)
print(img_array.shape)
Exemplo n.º 3
0
def fetch_card_img_s3(name, bucket=os.environ.get('POKEDEXR_S3')):
    s3 = boto3.resource('s3')
    x = s3.Object(bucket, f'card_images/original/{name}').get()
    src_img = PIL.imread(BytesIO(x['Body'].read()), 0)
    return src_img