Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,20 +2,26 @@ import gradio as gr
|
|
2 |
import numpy as np
|
3 |
import tensorflow as tf
|
4 |
|
5 |
-
#
|
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 |
-
#
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
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
|