This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from keras.utils.data_utils import Sequence | |
| from imblearn.over_sampling import RandomOverSampler | |
| from imblearn.keras import balanced_batch_generator | |
| class BalancedDataGenerator(Sequence): | |
| """ImageDataGenerator + RandomOversampling""" | |
| def __init__(self, x, y, datagen, batch_size=32): | |
| self.datagen = datagen | |
| self.batch_size = min(batch_size, x.shape[0]) | |
| datagen.fit(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import random | |
| from scipy import ndarray | |
| # image processing library | |
| import skimage as sk | |
| from skimage import transform | |
| from skimage import util | |
| from skimage import io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # from the guide https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html | |
| # and from other resources found, trying to achieve a good classifier based on Inveption V3 pre-trained netfork | |
| from keras.applications.inception_v3 import InceptionV3 | |
| from keras.preprocessing import image | |
| from keras.models import Model | |
| from keras.layers import Dense, GlobalAveragePooling2D | |
| from keras.preprocessing.image import ImageDataGenerator | |
| from keras import backend as K | |
| from keras.callbacks import ModelCheckpoint |