SocialAI commited on
Commit
a2f2d80
·
verified ·
1 Parent(s): c7aaf93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -8,6 +8,7 @@ import os
8
 
9
  model = tf.keras.models.load_model("fine_tuned_resnet50.h5")
10
  img_dim = (224, 224)
 
11
 
12
  # returning classifiers output
13
  def predict(img):
@@ -16,7 +17,9 @@ def predict(img):
16
  img_array = np.expand_dims(img_array, axis=0)
17
 
18
  prediction = model.predict(img_array)
19
- return prediction
 
 
20
 
21
  with gr.Blocks() as demo:
22
  gr.Markdown("# Lung Cancer Classifier")
 
8
 
9
  model = tf.keras.models.load_model("fine_tuned_resnet50.h5")
10
  img_dim = (224, 224)
11
+ lung_cancer_labels = ["Benign", "Malignant", "Normal"]
12
 
13
  # returning classifiers output
14
  def predict(img):
 
17
  img_array = np.expand_dims(img_array, axis=0)
18
 
19
  prediction = model.predict(img_array)
20
+ class_index = np.argmax(prediction)
21
+ confidence = np.max(prediction)
22
+ return f"{lung_cancer_labels[class_index]} (Confidence: {confidence:.2f})"
23
 
24
  with gr.Blocks() as demo:
25
  gr.Markdown("# Lung Cancer Classifier")