Spaces:
Runtime error
Runtime error
Commit ·
3834b22
1
Parent(s): c54d968
Update app.py
Browse files
app.py
CHANGED
|
@@ -116,6 +116,7 @@ def server(input: Inputs, output: Outputs, session: Session):
|
|
| 116 |
def uploaded_image_path() -> str:
|
| 117 |
"""Returns the path to the uploaded image"""
|
| 118 |
if input.tile_image() is not None:
|
|
|
|
| 119 |
return input.tile_image()[0]['datapath'] # Assuming multiple=False
|
| 120 |
else:
|
| 121 |
return "" # No image uploaded
|
|
@@ -126,6 +127,7 @@ def server(input: Inputs, output: Outputs, session: Session):
|
|
| 126 |
img_src = uploaded_image_path()
|
| 127 |
if img_src:
|
| 128 |
img: ImgData = {"src": str(dir / uploaded_image_path()), "width": "100px"}
|
|
|
|
| 129 |
return img
|
| 130 |
else:
|
| 131 |
return None # Return an empty string if no image is uploaded
|
|
@@ -232,12 +234,12 @@ def server(input: Inputs, output: Outputs, session: Session):
|
|
| 232 |
if image is None or prob is None or prediction is None:
|
| 233 |
# Return a placeholder plot or message
|
| 234 |
fig, ax = plt.subplots()
|
| 235 |
-
ax.text(0.5, 0.5, "Upload a square image to see predictions.
|
| 236 |
ax.axis("off") # Hide axis
|
| 237 |
plt.tight_layout()
|
| 238 |
return fig
|
| 239 |
|
| 240 |
-
fig, axes = plt.subplots(1, 4, figsize=(15,
|
| 241 |
|
| 242 |
# Extract the image data
|
| 243 |
#image_data = image.cpu().detach().numpy()
|
|
|
|
| 116 |
def uploaded_image_path() -> str:
|
| 117 |
"""Returns the path to the uploaded image"""
|
| 118 |
if input.tile_image() is not None:
|
| 119 |
+
print ("IMAGE PATH!!!!!!", input.tile_image()[0]['datapath'])
|
| 120 |
return input.tile_image()[0]['datapath'] # Assuming multiple=False
|
| 121 |
else:
|
| 122 |
return "" # No image uploaded
|
|
|
|
| 127 |
img_src = uploaded_image_path()
|
| 128 |
if img_src:
|
| 129 |
img: ImgData = {"src": str(dir / uploaded_image_path()), "width": "100px"}
|
| 130 |
+
print("IMAGE", img)
|
| 131 |
return img
|
| 132 |
else:
|
| 133 |
return None # Return an empty string if no image is uploaded
|
|
|
|
| 234 |
if image is None or prob is None or prediction is None:
|
| 235 |
# Return a placeholder plot or message
|
| 236 |
fig, ax = plt.subplots()
|
| 237 |
+
ax.text(0.5, 0.5, "Upload a square image to see predictions. Predictions will take a few moments to load.", fontsize=12, ha="center")
|
| 238 |
ax.axis("off") # Hide axis
|
| 239 |
plt.tight_layout()
|
| 240 |
return fig
|
| 241 |
|
| 242 |
+
fig, axes = plt.subplots(1, 4, figsize=(15, 15))
|
| 243 |
|
| 244 |
# Extract the image data
|
| 245 |
#image_data = image.cpu().detach().numpy()
|