Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
-
import
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
5 |
-
article = """---
|
6 |
-
This space was created using [SD Space Creator](https://huggingface.co/spaces/anzorq/sd-space-creator)."""
|
7 |
-
|
8 |
-
models = [
|
9 |
"models/ItsJayQz/Marvel_WhatIf_Diffusion",
|
10 |
"models/DGSpitzer/Cyberpunk-Anime-Diffusion",
|
11 |
"models/DGSpitzer/Guan-Yu-Diffusion",
|
@@ -16,22 +13,17 @@ models = [
|
|
16 |
"models/stabilityai/stable-diffusion-2-1"
|
17 |
]
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
fn= selectModel,
|
27 |
-
title="AlStable sandbox text to img",
|
28 |
-
name = models[3],
|
29 |
-
inputs = ["text", gr.Dropdown(models)],
|
30 |
-
outputs = "image",
|
31 |
-
description="Demo for <a href='https://huggingface.co/stabilityai/stable-diffusion-2-1'>AlStable</a> Stable Diffusion model.",
|
32 |
-
article=article,
|
33 |
-
api_key=API_KEY
|
34 |
-
)
|
35 |
|
36 |
-
sandbox.
|
|
|
|
|
|
|
37 |
|
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
import torch
|
3 |
import gradio as gr
|
4 |
|
5 |
+
models=[
|
|
|
|
|
|
|
|
|
6 |
"models/ItsJayQz/Marvel_WhatIf_Diffusion",
|
7 |
"models/DGSpitzer/Cyberpunk-Anime-Diffusion",
|
8 |
"models/DGSpitzer/Guan-Yu-Diffusion",
|
|
|
13 |
"models/stabilityai/stable-diffusion-2-1"
|
14 |
]
|
15 |
|
16 |
+
def TextToImage(Prompt,model):
|
17 |
+
model_id = model
|
18 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
19 |
+
pipe = pipe.to("cpu")
|
20 |
+
prompt = Prompt
|
21 |
+
image = pipe(prompt).images[0]
|
22 |
+
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
sandbox = gr.Interface(fn=TextToImage,
|
25 |
+
inputs=["text", gr.Dropdown(models)],
|
26 |
+
outputs="image",
|
27 |
+
title='AlStable Text to Image')
|
28 |
|
29 |
+
sandbox.launch()
|