CaxtonEmeraldS commited on
Commit
202c514
·
verified ·
1 Parent(s): 994a3de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -46,6 +46,11 @@ activations = sorted(activations)
46
  # Step 3: Prediction function
47
  def predict(r, g, b, activation, seed, neurons):
48
  try:
 
 
 
 
 
49
  X = np.array([[r, g, b]])
50
 
51
  # Linear prediction (you can replace this with your actual linear model)
@@ -59,7 +64,8 @@ def predict(r, g, b, activation, seed, neurons):
59
  model = tf.keras.models.load_model(keras_path)
60
  ann_pred = model.predict(X)[0][0]
61
 
62
- return ann_pred, lin_pred_rgb
 
63
 
64
  except Exception as e:
65
  return f"Error: {str(e)}", ""
@@ -78,14 +84,14 @@ with gr.Blocks() as demo:
78
  gr.Markdown("Dynamically select models and predict cholesterol concentration.")
79
 
80
  with gr.Row():
81
- r = gr.Number(label="R")
82
- g = gr.Number(label="G")
83
- b = gr.Number(label="B")
84
 
85
  with gr.Row():
86
  activation = gr.Dropdown(choices=activations, label="Activation Function", interactive=True)
87
- seed = gr.Dropdown(label="Seed", interactive=True)
88
- neurons = gr.Dropdown(label="Neurons", interactive=True)
89
 
90
  activation.change(update_seeds, inputs=[activation], outputs=[seed])
91
  seed.change(update_neurons, inputs=[activation, seed], outputs=[neurons])
@@ -94,8 +100,8 @@ with gr.Blocks() as demo:
94
  btn = gr.Button("Predict")
95
 
96
  with gr.Row():
97
- ann_output = gr.Text(label="ANN Model Prediction")
98
- lin_rgb_output = gr.Text(label="Linear RGB Prediction")
99
 
100
  btn.click(
101
  fn=predict,
 
46
  # Step 3: Prediction function
47
  def predict(r, g, b, activation, seed, neurons):
48
  try:
49
+ # Normalise R G B
50
+ r = r/255
51
+ g = g/255
52
+ b = b/255
53
+
54
  X = np.array([[r, g, b]])
55
 
56
  # Linear prediction (you can replace this with your actual linear model)
 
64
  model = tf.keras.models.load_model(keras_path)
65
  ann_pred = model.predict(X)[0][0]
66
 
67
+ # Rescale cholestrol concentration prediction in mM
68
+ return ann_pred*50, lin_pred_rgb*50
69
 
70
  except Exception as e:
71
  return f"Error: {str(e)}", ""
 
84
  gr.Markdown("Dynamically select models and predict cholesterol concentration.")
85
 
86
  with gr.Row():
87
+ r = gr.Number(label="R (0 -255)")
88
+ g = gr.Number(label="G (0 -255)")
89
+ b = gr.Number(label="B (0 -255)")
90
 
91
  with gr.Row():
92
  activation = gr.Dropdown(choices=activations, label="Activation Function", interactive=True)
93
+ seed = gr.Dropdown(choices=seed, label="Seed", interactive=True)
94
+ neurons = gr.Dropdown(choices=neurons, label="Neurons", interactive=True)
95
 
96
  activation.change(update_seeds, inputs=[activation], outputs=[seed])
97
  seed.change(update_neurons, inputs=[activation, seed], outputs=[neurons])
 
100
  btn = gr.Button("Predict")
101
 
102
  with gr.Row():
103
+ ann_output = gr.Text(label="Cholestrol Conentration (mM) - ANN Model Prediction ")
104
+ lin_rgb_output = gr.Text(label="Cholestrol Conentration (mM) - Linear Model Prediction")
105
 
106
  btn.click(
107
  fn=predict,