File size: 1,164 Bytes
8b81391
 
091d05d
8b81391
091d05d
8b81391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from diffusers import StableDiffusionPipeline, DiffusionPipeline
import torch
import gradio as gr
import spaces

css = """
#img-display-container {
    max-height: 50vh;
    }
#img-display-input {
    max-height: 40vh;
    }
#img-display-output {
    max-height: 40vh;
    }
"""

DEVICE = 'cuda'

model_id = "Onodofthenorth/SD_PixelArt_SpriteSheet_Generator"
pipe = StableDiffusionPipeline.from_pretrained(model_id, cache_dir="cache", torch_dtype=torch.float16)
pipe.to("cuda")


@spaces.GPU(enable_queue=True)
def generate_sprite(prompt):
    # pipe = pipe.to(DEVICE)
    image = pipe(prompt).images[0]
    return image

title = "# SD_PixelArt_SpriteSheet_Generator"
description = """Pixel Art Sprite Sheet Generator with Stable Diffusion Checkpoint."""

with gr.Blocks(css=css) as API:
    gr.Markdown(title)
    gr.Markdown(description)
        
    with gr.Column():
        inputs=gr.TextArea(label="Prompt", placeholder="Prompt")
        outputs=gr.Image(label="Ouput Image", type='pil', height=500)
    generate_btn = gr.Button(value="Generate")
    generate_btn.click(generate_sprite, inputs=inputs, outputs=outputs, api_name="generate_mesh")

API.launch()