szili2011 commited on
Commit
613f10b
1 Parent(s): c484425

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -2,20 +2,26 @@ import gradio as gr
2
  import numpy as np
3
  import tensorflow as tf
4
 
5
- # Assuming your model is loaded here
6
- model = tf.keras.models.load_model("pain_analysis.h5")
7
 
8
  def predict(image):
9
  image = np.array(image) / 255.0 # Normalize the image
10
- # Make predictions using your model here
11
- # result = model.predict(image)
12
- return result
 
13
 
14
- # Change this line to use gr.Image directly
 
 
 
 
 
15
  iface = gr.Interface(
16
  fn=predict,
17
  inputs=gr.Image(type="numpy"), # Use gr.Image directly
18
  outputs="label" # Specify the output type as needed
19
  )
20
 
21
- iface.launch()
 
2
  import numpy as np
3
  import tensorflow as tf
4
 
5
+ # Load your model here
6
+ model = tf.keras.models.load_model("pain_analysis.h5") # Ensure you replace this with your actual model path
7
 
8
  def predict(image):
9
  image = np.array(image) / 255.0 # Normalize the image
10
+ # Ensure the image is in the shape your model expects
11
+ image = np.expand_dims(image, axis=0) # Add batch dimension
12
+ # Make predictions using your model
13
+ result = model.predict(image) # Perform prediction
14
 
15
+ # If your model outputs a probability distribution, you might want to take the argmax
16
+ predicted_class = np.argmax(result, axis=1)
17
+
18
+ return predicted_class # Return the predicted class or whatever output format you need
19
+
20
+ # Use gr.Image directly for inputs
21
  iface = gr.Interface(
22
  fn=predict,
23
  inputs=gr.Image(type="numpy"), # Use gr.Image directly
24
  outputs="label" # Specify the output type as needed
25
  )
26
 
27
+ iface.launch(share=True) # Set share=True to create a public link