File size: 1,233 Bytes
8b81391
 
091d05d
ed1f3d9
8b81391
091d05d
8b81391
 
ed1f3d9
b9db5fb
 
 
ed1f3d9
b9db5fb
8b81391
 
e47304c
8b81391
f40690a
8b81391
 
 
 
 
 
ed1f3d9
 
 
8b81391
 
 
 
 
 
 
 
 
 
ed1f3d9
 
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-output {
    max-height: 60vh;
}

#img-display-output *{
    max-height: 60vh;
}
"""

DEVICE = 'cuda'
model_id = "Onodofthenorth/SD_PixelArt_SpriteSheet_Generator"
pipe = StableDiffusionPipeline.from_pretrained(model_id, 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]
    images = pipe(prompt).images
    return images

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', elem_id="img-display-output")
        outputs=gr.Gallery(label="Ouput Images", columns=4, elem_id="img-display-output")
    generate_btn = gr.Button(value="Generate")
    generate_btn.click(generate_sprite, inputs=inputs, outputs=outputs, api_name="generate_mesh")

API.launch()