Skip to content

Instantly share code, notes, and snippets.

---
layout: default
t:
first:
en: "This is my first sentence"
fr: "C'est ma premiàre phrase"
second:
en: "My second sentence"
fr: "Ma deuxième phrase"
third:
├── _site
| └── ...
├── _layouts
| ├── about
| | └──about_lyt.html
| └── hello_lyt.html
├── fr
| ├── à propos
| | └── apropos.html
| └── bonjour.html
├── fr
| ├── à propos
| | └── apropos.html
| └── bonjour.html
├── about
| └──about.html
└── hello.html
├── _config.yml
├── _layouts
| ├── default.html
| └── post.html
├── _site
| └── ...
└── index.html
from inception_resnet_v1 import *
def model_with_inception_resnet_base(pretrained_weights):
model = InceptionResNetV1()
if pretrained_weights == True:
#pre-trained weights https://drive.google.com/file/d/1971Xk5RwedbudGgTIrGAL4F7Aifu7id1/view?usp=sharing
model.load_weights('facenet_weights.h5')
new_model = models.Sequential()
Layer (type) Output Shape Param #
=================================================================
inception_resnet_v1 (Model) (None, 128) 22808144
_________________________________________________________________
dense_1 (Dense) (None, 256) 33024
_________________________________________________________________
dropout_1 (Dropout) (None, 256) 0
_________________________________________________________________
dense_2 (Dense) (None, 64) 16448
_________________________________________________________________
layer_outputs = [layer.output for layer in model.layers[:depth]]
activation_model = models.Model(inputs=model.input, outputs=layer_outputs)
predictions = models.predict(input_img_tensor)
@bpatra
bpatra / confusionreport.py
Last active December 5, 2020 23:21
confusionreport.py
from sklearn.metrics import classification_report, confusion_matrix
TEST_SIZE=200
target_names = ['J', 'L']
Y_pred = model_convenet_ad_hoc.predict_generator(test_generator, TEST_SIZE)
Y_pred = Y_pred.flatten()
y_pred_class = np.where(Y_pred > 0.5, 1, 0)
print('Classification Report')
print(classification_report(test_generator.classes, y_pred_class, target_names=target_names))
model.compile(loss='binary_crossentropy', optimizer=optimizers.RMSprop(lr=1e-3), metrics=['acc'])
history = model.fit_generator(train_generator, steps_per_epoch=steps_per_epoch, epochs=30, validation_data=validation_generator, validation_steps=50)
## Define TRAINING SET
train_datagen = ImageDataGenerator(rescale=1./255, rotation_range=0,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True, fill_mode='nearest')
train_generator = train_datagen.flow_from_directory(TRAIN_DIR,
target_size=(TARGET_SIZE, TARGET_SIZE),