Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,8 +147,15 @@ def process_image(image_input):
|
|
| 147 |
# Initialize the Gradio client with the URL of the Gradio server
|
| 148 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|
| 149 |
|
| 150 |
-
# Check if the image input is a
|
| 151 |
-
if isinstance(image_input,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
try:
|
| 153 |
# Try to decode if it's a base64 string
|
| 154 |
image = decode_image(image_input)
|
|
|
|
| 147 |
# Initialize the Gradio client with the URL of the Gradio server
|
| 148 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|
| 149 |
|
| 150 |
+
# Check if the image input is a NumPy array
|
| 151 |
+
if isinstance(image_input, np.ndarray):
|
| 152 |
+
# Convert the NumPy array to a PIL Image
|
| 153 |
+
image = Image.fromarray(image_input)
|
| 154 |
+
# Save the PIL Image to a temporary file
|
| 155 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp_file:
|
| 156 |
+
image.save(tmp_file.name)
|
| 157 |
+
image_path = tmp_file.name
|
| 158 |
+
elif isinstance(image_input, str):
|
| 159 |
try:
|
| 160 |
# Try to decode if it's a base64 string
|
| 161 |
image = decode_image(image_input)
|