AlStable commited on
Commit
e88fa1a
1 Parent(s): 3ad9190

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -44
app.py CHANGED
@@ -1,57 +1,42 @@
1
  import os
2
  import gradio as gr
3
- import logging
4
-
5
- LOG_FORMAT = '%(asctime)s - %(levelname)s [%(name)s] %(funcName)s -> %(message)s'
6
- logging.basicConfig(level = logging.DEBUG, format = LOG_FORMAT)
7
- logger = logging.getLogger(__name__)
8
- logger.debug('Logging started')
9
 
10
  API_KEY=os.environ.get('HUGGING_FACE_HUB_TOKEN', None)
11
  article = """---
12
  This space was created using [SD Space Creator](https://huggingface.co/spaces/anzorq/sd-space-creator)."""
 
13
 
14
- class Model:
15
- def __init__(self, name, path="", prefix=""):
16
- self.name = name
17
- self.path = path
18
- self.prefix = prefix
19
- self.pipe_t2i = None
20
- self.pipe_i2i = None
21
- models = [
22
- Model("Marvel","models/ItsJayQz/Marvel_WhatIf_Diffusion", "whatif style"),
23
- Model("Cyberpunk Anime Diffusion", "models/DGSpitzer/Cyberpunk-Anime-Diffusion", "dgs illustration style"),
24
- Model("Guan Yu Diffusion", "models/DGSpitzer/Guan-Yu-Diffusion", "Guan-Yu style"),
25
- Model("Portrait plus", "models/wavymulder/portraitplus", "portrait+ style"),
26
- Model("classic Disney", "models/nitrosocke/classic-anim-diffusion", "classic disney style"),
27
- Model("vintedois", "models/22h/vintedois-diffusion-v0-1", "vintedois style"),
28
- Model("dreamlike", "models/dreamlike-art/dreamlike-diffusion-1.0","dreamlike style"),
29
- Model("SD21","models/stabilityai/stable-diffusion-2-1", "sd21 default style")
30
  ]
31
 
32
- custom_model = "models/dreamlike-art/dreamlike-diffusion-1.0"
33
-
34
- def selectModel(message):
35
- message = message.lower()
36
- for i in range(len(models)):
37
- if message.find(models[i].prefix)!=-1:
38
- c_model=models[i].path
39
- logging.warning('model selected = '+c_model)
40
- return c_model
41
- c_model=models[i].path
42
- logging.warning('model selected = '+c_model)
43
- return c_model
44
-
45
- sandbox = gr.Interface.load(
46
- fn= selectModel,
47
- name= custom_model,
48
- title="""AlStable sandbox""",
49
- inputs = gr.Textbox(label="Prompt", show_label=False, max_lines=2, placeholder="Enter your prompt", elem_id="input-prompt"),
50
- description="""Demo for <a href="https://huggingface.co/stabilityai/stable-diffusion-2-1">AlStable</a> Stable Diffusion model.""",
51
  article=article,
52
- api_key=API_KEY
53
  )
54
 
55
- logging.warning('model chosen = '+custom_model)
56
-
57
  sandbox.queue(concurrency_count=20).launch()
 
 
1
  import os
2
  import gradio as gr
 
 
 
 
 
 
3
 
4
  API_KEY=os.environ.get('HUGGING_FACE_HUB_TOKEN', None)
5
  article = """---
6
  This space was created using [SD Space Creator](https://huggingface.co/spaces/anzorq/sd-space-creator)."""
7
+ import gradio as gr
8
 
9
+ article = """---This space was created using [SD Space Creator](https://huggingface.co/spaces/anzorq/sd-space-creator)."""
10
+
11
+ MODLS=[
12
+ "models/ItsJayQz/Marvel_WhatIf_Diffusion",
13
+ "models/DGSpitzer/Cyberpunk-Anime-Diffusion",
14
+ "models/DGSpitzer/Guan-Yu-Diffusion",
15
+ "models/wavymulder/portraitplus",
16
+ "models/nitrosocke/classic-anim-diffusion",
17
+ "models/22h/vintedois-diffusion-v0-1",
18
+ "models/dreamlike-art/dreamlike-diffusion-1.0",
19
+ "models/stabilityai/stable-diffusion-2-1"
 
 
 
 
 
20
  ]
21
 
22
+ TXT="AlStable Demo"
23
+
24
+ def prediction(input_choice):
25
+ return gr.Image(input_choice)
26
+
27
+ def prediction(model_choice, input):
28
+ modl = MODLS[model_choice]
29
+ return modl
30
+
31
+ sandbox = gr.Interface(
32
+ fn=prediction,
33
+ inputs=gr.inputs.Dropdown(MODLS),
34
+ outputs=gr.Image(),
35
+ title=TXT,
36
+ description=TXT,
 
 
 
 
37
  article=article,
38
+ api_key=API_KEY
39
  )
40
 
 
 
41
  sandbox.queue(concurrency_count=20).launch()
42
+