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
#!/bin/bash | |
DEVICE="HDMI-1" | |
IS_PRIMARY=`(xrandr --query --verbose | grep "$DEVICE" | cut -d ' ' -f 3)` | |
if [ "$IS_PRIMARY" == "primary" ]; then | |
CURRENT_ORIENTATION=`(xrandr --query --verbose | grep "$DEVICE" | cut -d ' ' -f 6)` | |
else | |
CURRENT_ORIENTATION=`(xrandr --query --verbose | grep "$DEVICE" | cut -d ' ' -f 5)` | |
fi | |
ORIENTATION_1="normal" |
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
import numpy as np | |
class Optimizer: | |
def __init__(self, mu=0.9, lr=0.01): | |
self.cache = {} | |
self.mu = mu | |
self.lr = lr | |
def update(self, name_w, old_w, dw): | |
if name_w in self.cache: |
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
raw_results = model.predict(images) | |
results = {} | |
labels = {0: 'cat', 1: 'dog'} | |
text_to_show = {'cat': 'meowww', 'dog': 'bupp'} | |
def drawText(im, text, color): | |
text_size = cv2.getTextSize(text, cv2.FONT_HERSHEY_SIMPLEX, 1, 2)[0] | |
text_pos_x = (im.shape[1] - text_size[0]) // 2 | |
text_pos_y = (im.shape[0] + text_size[1]) // 2 |
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
import numpy as np | |
import keras | |
from keras.preprocessing.image import ImageDataGenerator | |
# Indicamos Cada correspondiente carpeta | |
TRAIN_FOLDER = './dogscats/train/' | |
VAL_FOLDER = './dogscats/valid/' | |
# Indicamos como se cogeran las imagenes de entrenamiento y si habrá data-aumentation. | |
# Basicamente para tener más ejemplos, |
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
# Usamos fit generator para aprender. | |
# Definimos 50 epocas y 2000 iteraciones/epoca | |
# Indicamos que datos usaremos para validar el correcto aprendizaje y diagnostico | |
model.fit_generator( | |
train_generator, | |
steps_per_epoch=2000, | |
epochs=50, | |
validation_data=val_generator, | |
validation_steps=800) |
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
# Usamos el optimizador Adam | |
# Usamos la loss function binary_crossentropy. Esta es util cuando la red devuelve una probabilidad, es este caso ser perro o ser gato. | |
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['binary_accuracy']) | |
model.summary() |
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
# Cargamos la clase para generar modelos sequenciales | |
from keras.models import Sequential | |
# Cargamos las siguientes capas | |
from keras.layers import Conv2D, MaxPooling2D, Dense, Flatten | |
model = Sequential() | |
# Bloque 1: | |
# - Conv1a: neuronas=128, ventana=(3,3), activacion=ReLU. | |
# - Conv1b: neuronas=256, ventana=(3,3), activacion=ReLU. | |
# - Max-pooling: ventana=(3,3), stride=2. |
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
Epoch 50/50 | |
... | |
2000/2000 [==============================] - 158s 79ms/step - loss: 0.1001 - binary_accuracy: 0.9613 - val_loss: 0.6304 - val_binary_accuracy: 0.8426 |
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
# Cargamos la imagen/imagenes | |
if os.path.isdir(args.image): | |
path_images = [] | |
for ext in ['jpg', 'jpeg', 'tiff', 'png', 'gif']: | |
path_images += glob.glob(os.path.join(args.image, "*." + ext)) | |
else: | |
path_images = [args.image] | |
images = [] | |
for path_im in path_images: |
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
# Cargamos el modelo | |
json_file = open('model.json', 'r') | |
loaded_model_json = json_file.read() | |
json_file.close() | |
model = model_from_json(loaded_model_json) | |
model.load_weights("model.h5") |
NewerOlder