Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
import random
|
|
|
4 |
|
5 |
pipe = DiffusionPipeline.from_pretrained("UnfilteredAI/NSFW-gen-v2")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
# Define the Gradio interface
|
16 |
-
inputs = [
|
17 |
-
gr.Textbox(label="Prompt", default="A fantasy landscape", lines=2),
|
18 |
-
gr.Textbox(label="Negative Prompt", default="", lines=2),
|
19 |
-
gr.Slider(minimum=256, maximum=1024, step=64, default=1024, label="Height"),
|
20 |
-
gr.Slider(minimum=256, maximum=1024, step=64, default=1024, label="Width"),
|
21 |
-
gr.Number(default=None, label="Seed", optional=True)
|
22 |
-
]
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
import random
|
4 |
+
import spaces
|
5 |
|
6 |
pipe = DiffusionPipeline.from_pretrained("UnfilteredAI/NSFW-gen-v2")
|
7 |
|
8 |
+
@spaces.GPU
|
9 |
+
def generate(prompt, negative_prompt, num_inference_steps, guidance_scale, width, height, num_samples):
|
10 |
+
return pipe(
|
11 |
+
prompt=prompt
|
12 |
+
negative_prompt=negative_prompt,
|
13 |
+
num_inference_steps=num_inference_steps,
|
14 |
+
guidance_scale=guidance_scale,
|
15 |
+
width=width,
|
16 |
+
height=height,
|
17 |
+
num_images_per_prompt=num_samples
|
18 |
+
).images
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
gr.Interface(
|
22 |
+
fn=generate,
|
23 |
+
inputs=[
|
24 |
+
gr.Text(label="Prompt"),
|
25 |
+
gr.Text("", label="Negative Prompt"),
|
26 |
+
gr.Number(7, label="Number inference steps"),
|
27 |
+
gr.Number(3, label="Guidance scale"),
|
28 |
+
gr.Number(512, label="Width"),
|
29 |
+
gr.Number(512, label="Height"),
|
30 |
+
gr.Number(1, label="# images"),
|
31 |
+
],
|
32 |
+
outputs=gr.Gallery(),
|
33 |
+
).launch()
|