CharlieAmalet commited on
Commit
8b81391
1 Parent(s): 0f2e03d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -1
app.py CHANGED
@@ -1,3 +1,44 @@
 
 
1
  import gradio as gr
 
2
 
3
- gr.Interface.load("models/Onodofthenorth/SD_PixelArt_SpriteSheet_Generator").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import StableDiffusionPipeline, DiffusionPipeline
2
+ import torch
3
  import gradio as gr
4
+ import spaces
5
 
6
+ css = """
7
+ #img-display-container {
8
+ max-height: 50vh;
9
+ }
10
+ #img-display-input {
11
+ max-height: 40vh;
12
+ }
13
+ #img-display-output {
14
+ max-height: 40vh;
15
+ }
16
+ """
17
+
18
+ DEVICE = 'cuda'
19
+
20
+ model_id = "Onodofthenorth/SD_PixelArt_SpriteSheet_Generator"
21
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, cache_dir="cache", torch_dtype=torch.float16)
22
+ pipe.to("cuda")
23
+
24
+
25
+ @spaces.GPU(enable_queue=True)
26
+ def generate_sprite(prompt):
27
+ # pipe = pipe.to(DEVICE)
28
+ image = pipe(prompt).images[0]
29
+ return image
30
+
31
+ title = "# SD_PixelArt_SpriteSheet_Generator"
32
+ description = """Pixel Art Sprite Sheet Generator with Stable Diffusion Checkpoint."""
33
+
34
+ with gr.Blocks(css=css) as API:
35
+ gr.Markdown(title)
36
+ gr.Markdown(description)
37
+
38
+ with gr.Column():
39
+ inputs=gr.TextArea(label="Prompt", placeholder="Prompt")
40
+ outputs=gr.Image(label="Ouput Image", type='pil', height=500)
41
+ generate_btn = gr.Button(value="Generate")
42
+ generate_btn.click(generate_sprite, inputs=inputs, outputs=outputs, api_name="generate_mesh")
43
+
44
+ API.launch()