Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,25 +37,25 @@ def pix2pix(
|
|
| 37 |
|
| 38 |
generator = torch.Generator("cuda").manual_seed(seed)
|
| 39 |
|
| 40 |
-
try:
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
# return replace_nsfw_images(result)
|
| 56 |
return result[0]
|
| 57 |
-
except Exception as e:
|
| 58 |
-
|
| 59 |
|
| 60 |
|
| 61 |
|
|
|
|
| 37 |
|
| 38 |
generator = torch.Generator("cuda").manual_seed(seed)
|
| 39 |
|
| 40 |
+
#try:
|
| 41 |
+
image = Image.open(image)
|
| 42 |
+
ratio = min(height / image.height, width / image.width)
|
| 43 |
+
image = image.resize((int(image.width * ratio), int(image.height * ratio)), Image.LANCZOS)
|
| 44 |
+
|
| 45 |
+
result = pipe(
|
| 46 |
+
prompt,
|
| 47 |
+
image=image,
|
| 48 |
+
num_inference_steps=int(steps),
|
| 49 |
+
image_guidance_scale=image_guidance_scale,
|
| 50 |
+
guidance_scale=text_guidance_scale,
|
| 51 |
+
generator=generator,
|
| 52 |
+
negative_prompt=neg_prompt,
|
| 53 |
+
)
|
| 54 |
|
| 55 |
# return replace_nsfw_images(result)
|
| 56 |
return result[0]
|
| 57 |
+
#except Exception as e:
|
| 58 |
+
# return None
|
| 59 |
|
| 60 |
|
| 61 |
|