Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,15 +17,16 @@ def predict_regression(image):
|
|
17 |
image = image.resize((150, 150))
|
18 |
# If model expects RGB, convert to RGB
|
19 |
image = image.convert('RGB') # Ensure image is in RGB format
|
20 |
-
image = np.array(image, dtype=np.float32) # Convert image to float32
|
21 |
-
image /= 255.0 # Normalize image data to 0-1 range
|
22 |
|
23 |
-
|
|
|
|
|
24 |
# Predict
|
25 |
-
prediction = model.predict(image[None, ...]) #
|
26 |
confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
|
27 |
return confidences
|
28 |
|
|
|
29 |
# Create Gradio interface
|
30 |
input_image = gr.Image()
|
31 |
output_text = gr.Textbox(label="Predicted Value")
|
|
|
17 |
image = image.resize((150, 150))
|
18 |
# If model expects RGB, convert to RGB
|
19 |
image = image.convert('RGB') # Ensure image is in RGB format
|
|
|
|
|
20 |
|
21 |
+
|
22 |
+
image = np.array(image)
|
23 |
+
print(image.shape)
|
24 |
# Predict
|
25 |
+
prediction = model.predict(image[None, ...]) # Assuming single regression value
|
26 |
confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
|
27 |
return confidences
|
28 |
|
29 |
+
|
30 |
# Create Gradio interface
|
31 |
input_image = gr.Image()
|
32 |
output_text = gr.Textbox(label="Predicted Value")
|