Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,45 @@
|
|
1 |
from diffusers import StableDiffusionPipeline
|
2 |
import torch
|
3 |
-
import gradio
|
4 |
import accelerate
|
5 |
|
6 |
-
|
7 |
-
"
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
]
|
15 |
|
|
|
|
|
|
|
16 |
for i in range(len(models)):
|
17 |
-
|
|
|
18 |
|
19 |
-
def
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
sandbox =
|
28 |
-
inputs=["
|
29 |
-
outputs="
|
30 |
title='AlStable Text to Image')
|
31 |
-
|
32 |
-
sandbox.launch()
|
|
|
1 |
from diffusers import StableDiffusionPipeline
|
2 |
import torch
|
3 |
+
import gradio
|
4 |
import accelerate
|
5 |
|
6 |
+
class Model:
|
7 |
+
def __init__(self, name, path="", prefix=""):
|
8 |
+
self.name = name
|
9 |
+
self.path = path
|
10 |
+
self.prefix = prefix
|
11 |
+
|
12 |
+
models = [
|
13 |
+
Model("Marvel","models/ItsJayQz/Marvel_WhatIf_Diffusion", "whatif style"),
|
14 |
+
Model("Cyberpunk Anime Diffusion", "models/DGSpitzer/Cyberpunk-Anime-Diffusion", "dgs illustration style"),
|
15 |
+
Model("Portrait plus", "models/wavymulder/portraitplus", "portrait+ style"),
|
16 |
+
Model("classic Disney", "models/nitrosocke/classic-anim-diffusion", "classic disney style"),
|
17 |
+
Model("vintedois", "models/22h/vintedois-diffusion-v0-1", "vintedois style"),
|
18 |
+
Model("dreamlike", "models/dreamlike-art/dreamlike-diffusion-1.0","dreamlike style"),
|
19 |
+
Model("SD21","models/stabilityai/stable-diffusion-2-1", "sd21 default style")
|
20 |
]
|
21 |
|
22 |
+
model2=[]
|
23 |
+
model3=[]
|
24 |
+
|
25 |
for i in range(len(models)):
|
26 |
+
model3.append(models[i].name)
|
27 |
+
model2.append(models[i].prefix)
|
28 |
|
29 |
+
def process1(prompt):
|
30 |
+
modelSelected==''
|
31 |
+
for i in range(len(models)):
|
32 |
+
if message.find(models[i].prefix)!=-1:
|
33 |
+
modelSelected=models[i].path
|
34 |
+
gradio.Interface.load(modelSelected)
|
35 |
+
if (modelSelected==''):
|
36 |
+
modelSelected = "models/stabilityai/stable-diffusion-2-1"
|
37 |
+
gradio.Interface.load(modelSelected)
|
38 |
+
image_return = modelSelected(prompt)
|
39 |
+
return image_return
|
40 |
|
41 |
+
sandbox = gradio.Interface(fn=process1,
|
42 |
+
inputs=[gradio.Textbox(label="Enter Prompt:")],
|
43 |
+
outputs=[gradio.Image(label="Produced Image")],
|
44 |
title='AlStable Text to Image')
|
45 |
+
sandbox.queue(concurrency_count=20).launch()
|
|