Update app.py
Browse files
app.py
CHANGED
@@ -46,12 +46,12 @@ def resize_image_dimensions(
|
|
46 |
w_original, h_original = w, h
|
47 |
|
48 |
if w > h:
|
49 |
-
aspect_ratiow =
|
50 |
w = IMAGE_SIZE
|
51 |
h = IMAGE_SIZE * aspect_ratiow
|
52 |
|
53 |
if h > w:
|
54 |
-
aspect_ratioh =
|
55 |
w = IMAGE_SIZE * aspect_ratioh
|
56 |
h = IMAGE_SIZE
|
57 |
|
@@ -79,7 +79,7 @@ def resize_image_dimensions(
|
|
79 |
# new_width = new_width - (new_width % 32)
|
80 |
# new_height = new_height - (new_height % 32)
|
81 |
|
82 |
-
return int(
|
83 |
|
84 |
|
85 |
@spaces.GPU(duration=80)
|
@@ -100,7 +100,7 @@ def process(
|
|
100 |
|
101 |
if not image:
|
102 |
gr.Info("Please upload an image.")
|
103 |
-
return None, None
|
104 |
|
105 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
106 |
resized_image = image.resize((width, height), Image.LANCZOS)
|
@@ -110,6 +110,7 @@ def process(
|
|
110 |
|
111 |
# if not mask:
|
112 |
# gr.Info("Please draw a mask on the image.")
|
|
|
113 |
pipe2.load_lora_weights("SIGMitch/KIT")
|
114 |
result = pipe2(
|
115 |
prompt=input_text,
|
@@ -125,7 +126,7 @@ def process(
|
|
125 |
)
|
126 |
print('INFERENCE DONE')
|
127 |
#return result.images[0].resize((image.size), Image.LANCZOS), result.images[1].resize((image.size), Image.LANCZOS)
|
128 |
-
return result.images[0], None #result.images[1]
|
129 |
|
130 |
#resized_mask = mask.resize((width, height), Image.LANCZOS)
|
131 |
|
@@ -204,8 +205,8 @@ with gr.Blocks() as demo:
|
|
204 |
with gr.Column():
|
205 |
output_image_component = gr.Image(
|
206 |
type='pil', image_mode='RGB', label='Generated image', format="png")
|
207 |
-
output_image_component2 = gr.Image(
|
208 |
-
|
209 |
|
210 |
|
211 |
|
@@ -221,8 +222,8 @@ with gr.Blocks() as demo:
|
|
221 |
lorasteps
|
222 |
],
|
223 |
outputs=[
|
224 |
-
output_image_component,
|
225 |
-
output_image_component2
|
226 |
]
|
227 |
)
|
228 |
|
|
|
46 |
w_original, h_original = w, h
|
47 |
|
48 |
if w > h:
|
49 |
+
aspect_ratiow = h / w
|
50 |
w = IMAGE_SIZE
|
51 |
h = IMAGE_SIZE * aspect_ratiow
|
52 |
|
53 |
if h > w:
|
54 |
+
aspect_ratioh = w / h
|
55 |
w = IMAGE_SIZE * aspect_ratioh
|
56 |
h = IMAGE_SIZE
|
57 |
|
|
|
79 |
# new_width = new_width - (new_width % 32)
|
80 |
# new_height = new_height - (new_height % 32)
|
81 |
|
82 |
+
return int(w), int(h)
|
83 |
|
84 |
|
85 |
@spaces.GPU(duration=80)
|
|
|
100 |
|
101 |
if not image:
|
102 |
gr.Info("Please upload an image.")
|
103 |
+
return None# , None
|
104 |
|
105 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
106 |
resized_image = image.resize((width, height), Image.LANCZOS)
|
|
|
110 |
|
111 |
# if not mask:
|
112 |
# gr.Info("Please draw a mask on the image.")
|
113 |
+
|
114 |
pipe2.load_lora_weights("SIGMitch/KIT")
|
115 |
result = pipe2(
|
116 |
prompt=input_text,
|
|
|
126 |
)
|
127 |
print('INFERENCE DONE')
|
128 |
#return result.images[0].resize((image.size), Image.LANCZOS), result.images[1].resize((image.size), Image.LANCZOS)
|
129 |
+
return result.images[0]# , None #result.images[1]
|
130 |
|
131 |
#resized_mask = mask.resize((width, height), Image.LANCZOS)
|
132 |
|
|
|
205 |
with gr.Column():
|
206 |
output_image_component = gr.Image(
|
207 |
type='pil', image_mode='RGB', label='Generated image', format="png")
|
208 |
+
# output_image_component2 = gr.Image(
|
209 |
+
# type='pil', image_mode='RGB', label='Generated image', format="png")
|
210 |
|
211 |
|
212 |
|
|
|
222 |
lorasteps
|
223 |
],
|
224 |
outputs=[
|
225 |
+
output_image_component# ,
|
226 |
+
# output_image_component2
|
227 |
]
|
228 |
)
|
229 |
|