Spaces:
Runtime error
Runtime error
verkaDerkaDerk
commited on
Commit
•
5da5ea4
1
Parent(s):
7c4e0db
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
|
3 |
|
4 |
MODEL_ID = "verkaDerkaDerk/tiki-based-128"
|
@@ -6,17 +8,25 @@ MODEL_ID = "verkaDerkaDerk/tiki-64"
|
|
6 |
PIPELINE = DDPMPipeline.from_pretrained(MODEL_ID)
|
7 |
|
8 |
|
9 |
-
def imagineAll():
|
|
|
|
|
10 |
return PIPELINE()["sample"]
|
11 |
|
|
|
|
|
|
|
12 |
def imagine():
|
13 |
return imagineAll[0]
|
14 |
|
15 |
def fancy():
|
16 |
# try some https://huggingface.co/spaces/stabilityai/stable-diffusion/blob/main/app.py trix
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
with block:
|
21 |
gr.HTML('''
|
22 |
<pre>
|
@@ -42,9 +52,10 @@ def fancy():
|
|
42 |
|
43 |
gallery = gr.Gallery(
|
44 |
label="Generated images", show_label=False, elem_id="gallery"
|
45 |
-
).style(grid=[
|
|
|
|
|
46 |
|
47 |
-
btn.click(imagineAll, inputs=None, outputs=gallery)
|
48 |
gr.HTML('''
|
49 |
<p><img src="https://huggingface.co/spaces/verkaDerkaDerk/tiki-64/resolve/main/tiki-600e.png"></p>
|
50 |
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
import torch
|
4 |
from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
|
5 |
|
6 |
MODEL_ID = "verkaDerkaDerk/tiki-based-128"
|
|
|
8 |
PIPELINE = DDPMPipeline.from_pretrained(MODEL_ID)
|
9 |
|
10 |
|
11 |
+
def imagineAll(batch_size=1):
|
12 |
+
generator = torch.manual_seed(0)
|
13 |
+
return pipeline(generator=generator, batch_size=batch_size)["sample"]
|
14 |
return PIPELINE()["sample"]
|
15 |
|
16 |
+
def imagine4():
|
17 |
+
return imagineAll(4)
|
18 |
+
|
19 |
def imagine():
|
20 |
return imagineAll[0]
|
21 |
|
22 |
def fancy():
|
23 |
# try some https://huggingface.co/spaces/stabilityai/stable-diffusion/blob/main/app.py trix
|
24 |
+
css = '''
|
25 |
+
.output_image {height: 40rem !important; width: 100% !important; }
|
26 |
+
.object-contain {height: 256px !important; width: 256px !important; }
|
27 |
+
#gallery img { height: 256px !important; width: 256px !important; }
|
28 |
+
'''
|
29 |
+
block = gr.Blocks(css=css)
|
30 |
with block:
|
31 |
gr.HTML('''
|
32 |
<pre>
|
|
|
52 |
|
53 |
gallery = gr.Gallery(
|
54 |
label="Generated images", show_label=False, elem_id="gallery"
|
55 |
+
).style(grid=[4], height="256")
|
56 |
+
|
57 |
+
btn.click(imagine4, inputs=None, outputs=gallery)
|
58 |
|
|
|
59 |
gr.HTML('''
|
60 |
<p><img src="https://huggingface.co/spaces/verkaDerkaDerk/tiki-64/resolve/main/tiki-600e.png"></p>
|
61 |
|