Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,11 @@ def resize_image(image_path, target_height, output_path):
|
|
| 7 |
# Open the image file
|
| 8 |
with Image.open(image_path) as img:
|
| 9 |
# Calculate the ratio to resize the image to the target height
|
| 10 |
-
ratio = target_height / float(img.size[1])
|
| 11 |
# Calculate the new width based on the aspect ratio
|
| 12 |
-
new_width = int(float(img.size[0]) * ratio)
|
| 13 |
# Resize the image
|
| 14 |
-
resized_img = img.resize((
|
| 15 |
# Save the resized image
|
| 16 |
resized_img.save(output_path)
|
| 17 |
return output_path
|
|
@@ -66,7 +66,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 66 |
</h2>
|
| 67 |
<p style="text-align: center;">
|
| 68 |
Refining Malformed Hands in Generated Images by Diffusion-based Conditional Inpainting <br />
|
| 69 |
-
For demo purpose, every input images are resized to 512
|
| 70 |
</p>
|
| 71 |
<p style="margin:12px auto;display: flex;justify-content: center;">
|
| 72 |
<a href="https://huggingface.co/spaces/fffiloni/HandRefiner?duplicate=true"><img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space"></a>
|
|
|
|
| 7 |
# Open the image file
|
| 8 |
with Image.open(image_path) as img:
|
| 9 |
# Calculate the ratio to resize the image to the target height
|
| 10 |
+
#ratio = target_height / float(img.size[1])
|
| 11 |
# Calculate the new width based on the aspect ratio
|
| 12 |
+
#new_width = int(float(img.size[0]) * ratio)
|
| 13 |
# Resize the image
|
| 14 |
+
resized_img = img.resize((512, target_height), Image.LANCZOS)
|
| 15 |
# Save the resized image
|
| 16 |
resized_img.save(output_path)
|
| 17 |
return output_path
|
|
|
|
| 66 |
</h2>
|
| 67 |
<p style="text-align: center;">
|
| 68 |
Refining Malformed Hands in Generated Images by Diffusion-based Conditional Inpainting <br />
|
| 69 |
+
For demo purpose, every input images are resized to 512 1:1 aspect ratio
|
| 70 |
</p>
|
| 71 |
<p style="margin:12px auto;display: flex;justify-content: center;">
|
| 72 |
<a href="https://huggingface.co/spaces/fffiloni/HandRefiner?duplicate=true"><img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space"></a>
|