This file contains 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
df=pd.read_csv('./HARRISON/data_list.txt') | |
df2=pd.read_csv('./HARRISON/tag_list.txt') | |
df3 = pd.concat( [df, df2], axis=1) | |
df3.columns = ["path", "labels"] | |
for index, row in tqdm(df3.iterrows(), total=df3.shape[0]): | |
temp = row['labels'].replace(" ", ",") | |
temp = temp[:-1] | |
df3.at[index, 'labels'] = temp | |
df3.to_csv('./HARRISON/dataTest.txt', header=["path", "labels"], index=None, sep=',', mode='w') |
This file contains 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
colnames=['classe'] | |
df=pd.read_csv('./HARRISON/vocab_index.txt', names=colnames, header=None) | |
pattern=reg.compile(r"(.)\1{1,}",reg.DOTALL) | |
for index, row in tqdm(df.iterrows(), total=df.shape[0]): | |
temp = row['classe'].replace(" ", ",") | |
print(pattern.sub(r"\1",temp)) | |
df.at[index, 'classe'] = pattern.sub(r"\1",temp) | |
df.to_csv('./HARRISON/listClass.txt', header=["classe"], index=None, sep=',', mode='w') |
This file contains 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 PIL import ImageFile | |
ImageFile.LOAD_TRUNCATED_IMAGES = True |
This file contains 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
CLASSE = pd.read_csv("./HARRISON/listClass.txt",sep=',', names=["classe", "index"]) | |
df = pd.read_csv("./HARRISON/data.txt") | |
df["labels"]=df["labels"].apply(lambda x:x.split(",")) |
This file contains 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
NB_CLASSES = 994 # Permet de fix le nombre de classe manquante du dataset | |
NB_EPOCH = 1 | |
BATCH_SIZE = 32 | |
SHUFFLE = True | |
IMG_SIZE = (96,96) | |
TRAINSIZE_RATIO = 0.8 | |
TRAINSIZE = int(df.shape[0] * TRAINSIZE_RATIO) | |
LIST_CLASS = [] | |
DIRECTORY_DATA = "./HARRISON/" | |
DIRECTORY_TRAINED_MODEL = './trainedModel/model.hdf5' |
This file contains 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
save_model_callback = ModelCheckpoint(DIRECTORY_TRAINED_MODEL, | |
verbose=1, | |
save_best_only=True, | |
save_weights_only=False, | |
mode='auto', | |
period=1, | |
monitor='val_acc') | |
early_stopping = EarlyStopping(verbose=1,monitor='val_acc', min_delta=0, patience=3, mode='auto') |
This file contains 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
datagen=ImageDataGenerator(rescale=1./255.) | |
test_datagen=ImageDataGenerator(rescale=1./255.) |
This file contains 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
train_generator=datagen.flow_from_dataframe(dataframe=df[:TRAINSIZE], | |
directory=DIRECTORY_DATA, | |
x_col="path", | |
y_col="labels", | |
batch_size=BATCH_SIZE, | |
seed=42, | |
shuffle=SHUFFLE, | |
class_mode="categorical", | |
classes=LIST_CLASS, | |
target_size=IMG_SIZE, |
This file contains 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
labels = train_generator.class_indices | |
with open('./classIndice.txt', 'w') as file: | |
file.write(json.dumps(labels)) |
This file contains 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
baseModel = MobileNetV2(input_shape=(96,96,3), alpha=1.0, include_top=False, weights='imagenet', input_tensor=None, pooling='max') |
OlderNewer