Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,18 @@ def img2img( path ,design,x_prompt,alt_prompt,strength,guidance_scale,steps):
|
|
62 |
width1, height1 = img.size
|
63 |
#img = img.resize((512, 704), resample=Image.Resampling.BILINEAR)
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
try:
|
66 |
caption, keywords = generate_caption_keywords(design)
|
67 |
prompt = keywords
|
@@ -95,7 +107,9 @@ def img2img( path ,design,x_prompt,alt_prompt,strength,guidance_scale,steps):
|
|
95 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
96 |
img2 = Image.open(io.BytesIO(artifact.binary))
|
97 |
#img2 = img2.resize((width1, height1), resample=Image.Resampling.BILINEAR)
|
98 |
-
|
|
|
|
|
99 |
im1 = img2.save("new_image.jpg")
|
100 |
|
101 |
print(type(img2))
|
|
|
62 |
width1, height1 = img.size
|
63 |
#img = img.resize((512, 704), resample=Image.Resampling.BILINEAR)
|
64 |
|
65 |
+
###########
|
66 |
+
# Read the size of the image
|
67 |
+
width, height = img.size
|
68 |
+
|
69 |
+
# Calculate the new size of the image, making sure that the width and height are multiples of 64
|
70 |
+
new_width = ((width + 63) // 64) * 64
|
71 |
+
new_height = ((height + 63) // 64) * 64
|
72 |
+
|
73 |
+
# Resize the image
|
74 |
+
img = img.resize((new_width, new_height), resample=Image.Resampling.BILINEAR)
|
75 |
+
|
76 |
+
#######
|
77 |
try:
|
78 |
caption, keywords = generate_caption_keywords(design)
|
79 |
prompt = keywords
|
|
|
107 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
108 |
img2 = Image.open(io.BytesIO(artifact.binary))
|
109 |
#img2 = img2.resize((width1, height1), resample=Image.Resampling.BILINEAR)
|
110 |
+
###
|
111 |
+
img2 = img2.resize((new_width, new_height), resample=Image.Resampling.BILINEAR)
|
112 |
+
###
|
113 |
im1 = img2.save("new_image.jpg")
|
114 |
|
115 |
print(type(img2))
|