AlStable commited on
Commit
979d507
1 Parent(s): e88fa1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -21
app.py CHANGED
@@ -1,14 +1,17 @@
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",
@@ -19,24 +22,29 @@ MODLS=[
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
 
 
 
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
+ models = [
15
  "models/ItsJayQz/Marvel_WhatIf_Diffusion",
16
  "models/DGSpitzer/Cyberpunk-Anime-Diffusion",
17
  "models/DGSpitzer/Guan-Yu-Diffusion",
 
22
  "models/stabilityai/stable-diffusion-2-1"
23
  ]
24
 
25
+ custom_model = "models/dreamlike-art/dreamlike-diffusion-1.0"
26
+
27
+ def selectModel(message):
28
+ message = message.lower()
29
+ for i in range(len(models)):
30
+ if message.find(models[i].prefix)!=-1:
31
+ c_model=models[i].path
32
+ logging.warning('model selected = '+c_model)
33
+ return c_model
34
+ c_model=models[i].path
35
+ logging.warning('model selected = '+c_model)
36
+ return c_model
37
+
38
+ sandbox = gr.Interface.load(
39
+ fn= selectModel,
40
+ name= custom_model,
41
+ title="""AlStable sandbox""",
42
+ inputs = gr.Textbox(label="Prompt", show_label=False, max_lines=2, placeholder="Enter your prompt", elem_id="input-prompt"),
43
+ description="""Demo for <a href="https://huggingface.co/stabilityai/stable-diffusion-2-1">AlStable</a> Stable Diffusion model.""",
44
  article=article,
45
+ api_key=API_KEY
46
  )
47
 
48
+ logging.warning('model chosen = '+custom_model)
49
 
50
+ sandbox.queue(concurrency_count=20).launch()