AlStable commited on
Commit
5463328
1 Parent(s): bbf0543

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -22
app.py CHANGED
@@ -1,32 +1,45 @@
1
  from diffusers import StableDiffusionPipeline
2
  import torch
3
- import gradio as gr
4
  import accelerate
5
 
6
- models=[
7
- "ItsJayQz/Marvel_WhatIf_Diffusion",
8
- "DGSpitzer/Cyberpunk-Anime-Diffusion",
9
- "wavymulder/portraitplus",
10
- "nitrosocke/classic-anim-diffusion",
11
- "22h/vintedois-diffusion-v0-1",
12
- "dreamlike-art/dreamlike-diffusion-1.0",
13
- "stabilityai/stable-diffusion-2-1"
 
 
 
 
 
 
14
  ]
15
 
 
 
 
16
  for i in range(len(models)):
17
- gr.Interface.load(f"models/{models[i]}",live=True,preprocess=True)
 
18
 
19
- def TextToImage(Prompt,model):
20
- model_id = model
21
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.get_default_dtype())
22
- pipe = pipe.to("cpu")
23
- prompt = Prompt
24
- image = pipe(prompt).images[0]
25
- return image
 
 
 
 
26
 
27
- sandbox = gr.Interface(fn=TextToImage,
28
- inputs=["text", gr.Dropdown(models)],
29
- outputs="image",
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()