Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
import tensorflow as tf
|
2 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
3 |
|
4 |
#Preprocesamiento de imagenes del conjunto de entrenamiento
|
5 |
training_set = tf.keras.utils.image_dataset_from_directory(
|
@@ -68,4 +72,22 @@ model.add(tf.keras.layers.Dropout(0.5)) #To avoid overfitting
|
|
68 |
|
69 |
|
70 |
#Output Layer
|
71 |
-
model.add(tf.keras.layers.Dense(units=36,activation='softmax'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import tensorflow as tf
|
2 |
import matplotlib.pyplot as plt
|
3 |
+
from tensorflow.keras.callbacks import ModelCheckpoint
|
4 |
+
import tensorflow as tf
|
5 |
+
import datetime
|
6 |
+
|
7 |
|
8 |
#Preprocesamiento de imagenes del conjunto de entrenamiento
|
9 |
training_set = tf.keras.utils.image_dataset_from_directory(
|
|
|
72 |
|
73 |
|
74 |
#Output Layer
|
75 |
+
model.add(tf.keras.layers.Dense(units=36,activation='softmax'))
|
76 |
+
|
77 |
+
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy',"mean_absolute_error","Precision","Recall",tf.keras.metrics.AUC()])
|
78 |
+
|
79 |
+
%load_ext tensorboard
|
80 |
+
#!rm -rf ./logs/
|
81 |
+
log_dir = "logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
82 |
+
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
|
83 |
+
|
84 |
+
#Entrenar el modelo desde la ultima epoca almacenada usando el parametro initial_epoch
|
85 |
+
history = model.fit(x=training_set,validation_data=validation_set, epochs=epochs, initial_epoch=max_num, callbacks=[tensorboard_callback, checkpoint_callback])
|
86 |
+
|
87 |
+
#Precisión del conjunto de entrenamiento
|
88 |
+
train_loss, train_acc = model.evaluate(training_set)
|
89 |
+
print('Training accuracy:', train_acc)
|
90 |
+
|
91 |
+
#Precisión del conjunto de validación
|
92 |
+
val_loss, val_acc = model.evaluate(validation_set)
|
93 |
+
print('Validation accuracy:', val_acc)
|