szili2011 commited on
Commit
e13a0a4
1 Parent(s): 6ac8084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -1,23 +1,21 @@
1
  import gradio as gr
 
2
  import tensorflow as tf
3
 
4
- # Load your model
5
- model = tf.keras.models.load_model("pain_analysis.h5")
6
 
7
  def predict(image):
8
- # Preprocess the image as required by your model
9
- image = image.resize((150, 150)) # Assuming your model expects 150x150 input
10
  image = np.array(image) / 255.0 # Normalize the image
11
- image = np.expand_dims(image, axis=0) # Add batch dimension
12
- predictions = model.predict(image)
13
- return predictions.tolist() # Adjust the output format as needed
14
 
15
- # Define the Gradio interface
16
- inputs = gr.Image(type="pil") # Updated input definition
17
- outputs = gr.Label(num_top_classes=4) # Adjust according to your model's output
 
 
 
18
 
19
- interface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs, title="Pain Analysis Model")
20
-
21
- # Launch the app
22
- if __name__ == "__main__":
23
- interface.launch()
 
1
  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()