Spaces:
Sleeping
Sleeping
Commit ·
6f66313
1
Parent(s): 644ee3f
changed a few files to handle the PIL
Browse files
app.py
CHANGED
|
@@ -86,18 +86,23 @@ def predict_blood_group(input_image):
|
|
| 86 |
logging.error(f"Prediction error: {str(e)}", exc_info=True)
|
| 87 |
return f"Error: {str(e)}", "0.0%"
|
| 88 |
|
| 89 |
-
def gradio_predict(
|
| 90 |
"""
|
| 91 |
-
Gradio wrapper for prediction
|
| 92 |
"""
|
| 93 |
try:
|
| 94 |
-
logging.info(f"Gradio predict called with image: {
|
| 95 |
|
| 96 |
-
if
|
| 97 |
-
logging.warning("No image provided")
|
| 98 |
return "Please upload an image", "No confidence"
|
| 99 |
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
if predicted_group.startswith("Error"):
|
| 103 |
logging.error(f"Prediction failed: {predicted_group}")
|
|
@@ -113,7 +118,7 @@ def gradio_predict(image):
|
|
| 113 |
# Create Gradio interface
|
| 114 |
iface = gr.Interface(
|
| 115 |
fn=gradio_predict,
|
| 116 |
-
inputs=gr.Image(type="
|
| 117 |
outputs=[
|
| 118 |
gr.Textbox(label="Predicted Blood Group"),
|
| 119 |
gr.Textbox(label="Confidence")
|
|
|
|
| 86 |
logging.error(f"Prediction error: {str(e)}", exc_info=True)
|
| 87 |
return f"Error: {str(e)}", "0.0%"
|
| 88 |
|
| 89 |
+
def gradio_predict(image_path):
|
| 90 |
"""
|
| 91 |
+
Gradio wrapper for prediction - handles file paths
|
| 92 |
"""
|
| 93 |
try:
|
| 94 |
+
logging.info(f"Gradio predict called with image path: {image_path}")
|
| 95 |
|
| 96 |
+
if image_path is None:
|
| 97 |
+
logging.warning("No image path provided")
|
| 98 |
return "Please upload an image", "No confidence"
|
| 99 |
|
| 100 |
+
# Verify file exists
|
| 101 |
+
if not os.path.exists(image_path):
|
| 102 |
+
logging.error(f"Image file not found: {image_path}")
|
| 103 |
+
return "Error: Image file not found", "0.0%"
|
| 104 |
+
|
| 105 |
+
predicted_group, confidence = predict_blood_group(image_path)
|
| 106 |
|
| 107 |
if predicted_group.startswith("Error"):
|
| 108 |
logging.error(f"Prediction failed: {predicted_group}")
|
|
|
|
| 118 |
# Create Gradio interface
|
| 119 |
iface = gr.Interface(
|
| 120 |
fn=gradio_predict,
|
| 121 |
+
inputs=gr.Image(type="filepath", label="Upload Blood Sample Image"),
|
| 122 |
outputs=[
|
| 123 |
gr.Textbox(label="Predicted Blood Group"),
|
| 124 |
gr.Textbox(label="Confidence")
|