Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,20 +17,26 @@ except Exception as e:
|
|
| 17 |
|
| 18 |
def process_image(prompt, image, style, upscale_factor, inpaint):
|
| 19 |
try:
|
| 20 |
-
# Debug the type of image received
|
|
|
|
|
|
|
|
|
|
| 21 |
print(f"Received image type: {type(image)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
if
|
| 25 |
-
|
| 26 |
-
image = Image.fromarray(image)
|
| 27 |
-
elif isinstance(image, torch.Tensor):
|
| 28 |
-
image = transforms.ToPILImage()(image)
|
| 29 |
-
elif isinstance(image, Image.Image):
|
| 30 |
-
# Image is already in the correct format
|
| 31 |
-
pass
|
| 32 |
-
else:
|
| 33 |
-
return None, f"Error: Unsupported image format. Received {type(image)}."
|
| 34 |
|
| 35 |
# Log the input parameters
|
| 36 |
print(f"Prompt: {prompt}")
|
|
|
|
| 17 |
|
| 18 |
def process_image(prompt, image, style, upscale_factor, inpaint):
|
| 19 |
try:
|
| 20 |
+
# Debug the type and content of image received
|
| 21 |
+
if image is None:
|
| 22 |
+
return None, "No image received."
|
| 23 |
+
|
| 24 |
print(f"Received image type: {type(image)}")
|
| 25 |
+
|
| 26 |
+
if isinstance(image, np.ndarray):
|
| 27 |
+
print(f"Image shape: {image.shape}")
|
| 28 |
+
image = Image.fromarray(image)
|
| 29 |
+
elif isinstance(image, torch.Tensor):
|
| 30 |
+
print(f"Image tensor shape: {image.shape}")
|
| 31 |
+
image = transforms.ToPILImage()(image)
|
| 32 |
+
elif isinstance(image, Image.Image):
|
| 33 |
+
print("Image is already in PIL format.")
|
| 34 |
+
else:
|
| 35 |
+
return None, f"Unsupported image format: {type(image)}."
|
| 36 |
|
| 37 |
+
# Check if the image is valid
|
| 38 |
+
if not isinstance(image, Image.Image):
|
| 39 |
+
return None, "Error: Image format conversion failed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# Log the input parameters
|
| 42 |
print(f"Prompt: {prompt}")
|