Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
import torch
|
3 |
+
|
4 |
+
modelieo=[
|
5 |
+
'naclbit/trinart_stable_diffusion_v2',
|
6 |
+
]
|
7 |
+
|
8 |
+
|
9 |
+
def TextToImage(Prompt,model):
|
10 |
+
model_id = model
|
11 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
12 |
+
pipe = pipe.to("cpu")
|
13 |
+
|
14 |
+
prompt = Prompt
|
15 |
+
image = pipe(prompt).images[0]
|
16 |
+
|
17 |
+
return image
|
18 |
+
|
19 |
+
|
20 |
import gradio as gr
|
21 |
+
interface = gr.Interface(fn=TextToImage,
|
22 |
+
inputs=["text", gr.Dropdown(modelieo)],
|
23 |
+
outputs="image",
|
24 |
+
title='Text to Image')
|
25 |
|
26 |
+
interface.launch()
|