Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,26 +11,6 @@ from PIL import Image, ImageOps
|
|
11 |
from torchvision import transforms
|
12 |
|
13 |
|
14 |
-
'''import spaces
|
15 |
-
from diffusers import DiffusionPipeline
|
16 |
-
|
17 |
-
pipe = DiffusionPipeline.from_pretrained(...)
|
18 |
-
pipe.to('cuda')
|
19 |
-
|
20 |
-
@spaces.GPU
|
21 |
-
def generate(prompt):
|
22 |
-
return pipe(prompt).images
|
23 |
-
|
24 |
-
gr.Interface(
|
25 |
-
fn=generate,
|
26 |
-
inputs=gr.Text(),
|
27 |
-
outputs=gr.Gallery(),
|
28 |
-
).launch()
|
29 |
-
|
30 |
-
@spaces.GPU(duration=120)
|
31 |
-
def generate(prompt):
|
32 |
-
return pipe(prompt).images'''
|
33 |
-
|
34 |
# ----------------- HELPER FUNCTIONS ----------------- #
|
35 |
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
36 |
ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
|
@@ -193,7 +173,7 @@ def resize_and_pad(image: Image.Image, target_size=(768, 1024)):
|
|
193 |
new_height = target_size[1]
|
194 |
new_width = int(target_size[1] * img_ratio)
|
195 |
|
196 |
-
resized_image = image.resize((new_width, new_height), Image.
|
197 |
|
198 |
delta_w = target_size[0] - new_width
|
199 |
delta_h = target_size[1] - new_height
|
@@ -220,11 +200,12 @@ with open("tips.html", "r") as file:
|
|
220 |
tips = file.read()
|
221 |
|
222 |
CUSTOM_CSS = """
|
223 |
-
.image-container
|
224 |
max-width: 512px;
|
225 |
max-height: 512px;
|
226 |
margin: 0 auto;
|
227 |
border-radius: 0px;
|
|
|
228 |
.gradio-container {background-color: #fafafa}
|
229 |
"""
|
230 |
|
|
|
11 |
from torchvision import transforms
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# ----------------- HELPER FUNCTIONS ----------------- #
|
15 |
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
16 |
ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
|
|
|
173 |
new_height = target_size[1]
|
174 |
new_width = int(target_size[1] * img_ratio)
|
175 |
|
176 |
+
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
177 |
|
178 |
delta_w = target_size[0] - new_width
|
179 |
delta_h = target_size[1] - new_height
|
|
|
200 |
tips = file.read()
|
201 |
|
202 |
CUSTOM_CSS = """
|
203 |
+
.image-container img {
|
204 |
max-width: 512px;
|
205 |
max-height: 512px;
|
206 |
margin: 0 auto;
|
207 |
border-radius: 0px;
|
208 |
+
}
|
209 |
.gradio-container {background-color: #fafafa}
|
210 |
"""
|
211 |
|