tonyliu404 commited on
Commit
ec7bb7d
·
verified ·
1 Parent(s): 990436a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -16
app.py CHANGED
@@ -204,7 +204,7 @@ img_size = 224
204
 
205
  @st.cache_resource
206
  def loadModel():
207
- model = load_model('Final_CTP_Model.keras')
208
  return model
209
 
210
  model = loadModel()
@@ -231,7 +231,7 @@ class_names = [
231
 
232
  def classifyImage(input_image):
233
  input_image = input_image.resize((img_size, img_size))
234
- input_array = tf.keras.utils.img_to_array(input_image) / 255.0
235
 
236
  # Add a batch dimension
237
  input_array = tf.expand_dims(input_array, 0) # (1, 224, 224, 3)
@@ -239,20 +239,6 @@ def classifyImage(input_image):
239
  predictions = model.predict(input_array)[0]
240
  print(f"Predictions: {predictions}")
241
 
242
-
243
- probability_sum = predictions.sum() * 100
244
- print(f"Sum of predictions BEFORE SOFTMAX(as percentages): {probability_sum:.2f}%")
245
-
246
-
247
- predictions = tf.nn.softmax(predictions).numpy() #testing
248
- print(f"Predictions AFTER SOFTMAX: {predictions}")
249
-
250
- probability_sum = predictions.sum() * 100
251
- print(f"Sum of predictions AFTER SOFTMAX(as percentages): {probability_sum:.2f}%")
252
-
253
- for i, confidence in enumerate(predictions):
254
- print(f"Class {i} has {confidence*100:.2f}% confidence")
255
-
256
  # Sort predictions to get top 5
257
  top_indices = np.argsort(predictions)[-5:][::-1]
258
 
 
204
 
205
  @st.cache_resource
206
  def loadModel():
207
+ model = load_model('efficientnet-fine-d1.keras')
208
  return model
209
 
210
  model = loadModel()
 
231
 
232
  def classifyImage(input_image):
233
  input_image = input_image.resize((img_size, img_size))
234
+ input_array = tf.keras.utils.img_to_array(input_image)
235
 
236
  # Add a batch dimension
237
  input_array = tf.expand_dims(input_array, 0) # (1, 224, 224, 3)
 
239
  predictions = model.predict(input_array)[0]
240
  print(f"Predictions: {predictions}")
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  # Sort predictions to get top 5
243
  top_indices = np.argsort(predictions)[-5:][::-1]
244