andromeda01111 commited on
Commit
488254a
Β·
verified Β·
1 Parent(s): 084cbbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -38,7 +38,9 @@ class_names = ["Benign", "Malignant"]
38
 
39
  # Load trained Neural Network model (TensorFlow/Keras)
40
  nn_model_path = "my_NN_BC_model.keras"
41
- nn_model = None
 
 
42
  if os.path.exists(nn_model_path):
43
  try:
44
  nn_model = tf.keras.models.load_model(nn_model_path)
@@ -80,7 +82,7 @@ def classify(model_choice, image=None, *features):
80
  output = vit_model(input_tensor)
81
  predicted_class = torch.argmax(output, dim=1).item()
82
 
83
- return f"πŸ” **Prediction:** {class_names[predicted_class]}"
84
 
85
  elif model_choice == "Neural Network":
86
  if any(f is None for f in features):
@@ -91,7 +93,7 @@ def classify(model_choice, image=None, *features):
91
  prediction = nn_model.predict(input_data_std) if nn_model else [[0, 1]]
92
  predicted_class = np.argmax(prediction)
93
 
94
- return f"πŸ” **Prediction:** {class_names[predicted_class]}"
95
 
96
  # Gradio UI
97
  with gr.Blocks() as demo:
@@ -117,8 +119,8 @@ with gr.Blocks() as demo:
117
  return {feature_inputs[i]: example[i] for i in range(len(feature_inputs))}
118
 
119
  with gr.Row():
120
- example_btn_1 = gr.Button("πŸ”΅ Benign Example")
121
- example_btn_2 = gr.Button("πŸ”΄ Malignant Example")
122
 
123
  output_text = gr.Textbox(label="πŸ” Model Prediction", interactive=False)
124
 
 
38
 
39
  # Load trained Neural Network model (TensorFlow/Keras)
40
  nn_model_path = "my_NN_BC_model.keras"
41
+
42
+ nn_model = tf.keras.models.load_model(nn_model_path)
43
+
44
  if os.path.exists(nn_model_path):
45
  try:
46
  nn_model = tf.keras.models.load_model(nn_model_path)
 
82
  output = vit_model(input_tensor)
83
  predicted_class = torch.argmax(output, dim=1).item()
84
 
85
+ return class_names[predicted_class]
86
 
87
  elif model_choice == "Neural Network":
88
  if any(f is None for f in features):
 
93
  prediction = nn_model.predict(input_data_std) if nn_model else [[0, 1]]
94
  predicted_class = np.argmax(prediction)
95
 
96
+ return class_names[predicted_class]
97
 
98
  # Gradio UI
99
  with gr.Blocks() as demo:
 
119
  return {feature_inputs[i]: example[i] for i in range(len(feature_inputs))}
120
 
121
  with gr.Row():
122
+ example_btn_1 = gr.Button("πŸ”΅ Malignant Example")
123
+ example_btn_2 = gr.Button("πŸ”΄ Benign Example")
124
 
125
  output_text = gr.Textbox(label="πŸ” Model Prediction", interactive=False)
126