AlStable commited on
Commit
74a947f
1 Parent(s): 6add3fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -23
app.py CHANGED
@@ -1,11 +1,8 @@
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
-
8
- models = [
9
  "models/ItsJayQz/Marvel_WhatIf_Diffusion",
10
  "models/DGSpitzer/Cyberpunk-Anime-Diffusion",
11
  "models/DGSpitzer/Guan-Yu-Diffusion",
@@ -16,22 +13,17 @@ models = [
16
  "models/stabilityai/stable-diffusion-2-1"
17
  ]
18
 
19
- custom_model = "models/dreamlike-art/dreamlike-diffusion-1.0"
20
-
21
- def selectModel(message, models):
22
- message = message.lower()
23
- return models
24
-
25
- sandbox = gr.Interface.load(
26
- fn= selectModel,
27
- title="AlStable sandbox text to img",
28
- name = models[3],
29
- inputs = ["text", gr.Dropdown(models)],
30
- outputs = "image",
31
- description="Demo for <a href='https://huggingface.co/stabilityai/stable-diffusion-2-1'>AlStable</a> Stable Diffusion model.",
32
- article=article,
33
- api_key=API_KEY
34
- )
35
 
36
- sandbox.queue(concurrency_count=20).launch()
 
 
 
37
 
 
 
1
+ from diffusers import StableDiffusionPipeline
2
+ import torch
3
  import gradio as gr
4
 
5
+ models=[
 
 
 
 
6
  "models/ItsJayQz/Marvel_WhatIf_Diffusion",
7
  "models/DGSpitzer/Cyberpunk-Anime-Diffusion",
8
  "models/DGSpitzer/Guan-Yu-Diffusion",
 
13
  "models/stabilityai/stable-diffusion-2-1"
14
  ]
15
 
16
+ def TextToImage(Prompt,model):
17
+ model_id = model
18
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
19
+ pipe = pipe.to("cpu")
20
+ prompt = Prompt
21
+ image = pipe(prompt).images[0]
22
+ return image
 
 
 
 
 
 
 
 
 
23
 
24
+ sandbox = gr.Interface(fn=TextToImage,
25
+ inputs=["text", gr.Dropdown(models)],
26
+ outputs="image",
27
+ title='AlStable Text to Image')
28
 
29
+ sandbox.launch()