Spaces:
Paused
Paused
uuu
Browse files
app.py
CHANGED
|
@@ -63,12 +63,16 @@ pipe.init_ipadapter(
|
|
| 63 |
# ----------------------------
|
| 64 |
def preprocess_image(image_path):
|
| 65 |
"""Preprocess the input image for the pipeline."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
preprocess = transforms.Compose([
|
| 67 |
transforms.Resize((384, 384)),
|
| 68 |
transforms.ToTensor(),
|
| 69 |
transforms.ConvertImageDtype(torch.float16)
|
| 70 |
])
|
| 71 |
-
image = Image.open(image_path).convert('RGB')
|
| 72 |
return preprocess(image).unsqueeze(0).to("cuda")
|
| 73 |
|
| 74 |
# ----------------------------
|
|
@@ -130,4 +134,4 @@ interface = gr.Interface(
|
|
| 130 |
# ----------------------------
|
| 131 |
# Step 8: Launch Gradio App
|
| 132 |
# ----------------------------
|
| 133 |
-
interface.launch(
|
|
|
|
| 63 |
# ----------------------------
|
| 64 |
def preprocess_image(image_path):
|
| 65 |
"""Preprocess the input image for the pipeline."""
|
| 66 |
+
image = Image.open(image_path).convert("RGB")
|
| 67 |
+
# Ensure image is resized into a square based on the max dimension
|
| 68 |
+
size = max(image.size)
|
| 69 |
+
image = image.resize((size, size))
|
| 70 |
+
|
| 71 |
preprocess = transforms.Compose([
|
| 72 |
transforms.Resize((384, 384)),
|
| 73 |
transforms.ToTensor(),
|
| 74 |
transforms.ConvertImageDtype(torch.float16)
|
| 75 |
])
|
|
|
|
| 76 |
return preprocess(image).unsqueeze(0).to("cuda")
|
| 77 |
|
| 78 |
# ----------------------------
|
|
|
|
| 134 |
# ----------------------------
|
| 135 |
# Step 8: Launch Gradio App
|
| 136 |
# ----------------------------
|
| 137 |
+
interface.launch()
|