NORLIE JHON MALAGDAO commited on
Commit
543be11
·
verified ·
1 Parent(s): c477f1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -104,7 +104,7 @@ history = model.fit(
104
  train_ds,
105
  validation_data=val_ds,
106
  epochs=epochs,
107
- callbacks=[early_stopping]
108
  )
109
 
110
  # Evaluate the model on validation data
@@ -131,13 +131,14 @@ plt.legend()
131
  plt.title('Training and Validation Accuracy')
132
  plt.show()
133
 
134
- # Prediction function
135
  def predict_image(img):
136
  img = np.array(img)
137
  img_resized = tf.image.resize(img, (img_height, img_width))
138
  img_4d = tf.expand_dims(img_resized, axis=0)
139
- prediction = model.predict(img_4d)[0]
140
- return {class_names[i]: float(prediction[i]) for i in range(num_classes)}
 
 
141
 
142
  # Interface
143
  image = gr.Image()
 
104
  train_ds,
105
  validation_data=val_ds,
106
  epochs=epochs,
107
+
108
  )
109
 
110
  # Evaluate the model on validation data
 
131
  plt.title('Training and Validation Accuracy')
132
  plt.show()
133
 
 
134
  def predict_image(img):
135
  img = np.array(img)
136
  img_resized = tf.image.resize(img, (img_height, img_width))
137
  img_4d = tf.expand_dims(img_resized, axis=0)
138
+ logits = model.predict(img_4d)[0]
139
+ probabilities = tf.nn.softmax(logits)
140
+ return {class_names[i]: float(probabilities[i]) for i in range(num_classes)}
141
+
142
 
143
  # Interface
144
  image = gr.Image()