File size: 2,460 Bytes
9224595
6d48f70
 
 
 
 
 
 
 
 
 
 
 
9224595
6d48f70
 
 
9224595
6d48f70
 
 
 
 
 
7e48897
6d48f70
 
 
 
9e46ec0
6d48f70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1d8d14e
 
 
95cb04d
 
1d8d14e
 
95cb04d
 
1d8d14e
 
 
ca556f3
6d48f70
15af579
6d48f70
1d8d14e
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import gradio as gr
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline
import random

model = "Laughify/among-us-logic-ai-characters"
device = "cpu"

pipe = StableDiffusionPipeline.from_pretrained(model, torch_dtype=torch.float32)
pipe = pipe.to(device)

block = gr.Blocks(css=".container { max-width: 800px; margin: auto; }")

def infer(prompt, width, height, nums, steps, guidance_scale, seed):
    print(prompt)
    print(width, height, nums, steps, guidance_scale, seed)

    if prompt is not None and prompt != "":
        if seed is None or seed == '' or seed == -1:
            seed = int(random.randrange(4294967294))
        generator = torch.Generator(device).manual_seed(seed)
        images = pipe([prompt] * nums, height=height, width=width, num_inference_steps=steps, generator=generator, guidance_scale=guidance_scale )["sample"]
    return images

# with block as demo:
def run():
    _app = gr.Interface(
        fn=infer,
        title="Among Us Logic AI Character Generator",
        inputs=[
            gr.Textbox(label="prompt"),
            gr.Slider(512, 1024, 512, step=64, label="width"),
            gr.Slider(512, 1024, 512, step=64, label="height"),
            gr.Slider(1, 4, 1, step=1, label="Number of Images"),
            gr.Slider(10, 150, step=1, value=50,
                      label="num_inference_steps:\n"
                            "The number of denoising steps. More de-scaling steps usually result in a higher quality image, but will slow down inference."),
            gr.Slider(0, 20, 7.5, step=0.5,
                      label="guidance_scale:\n" +
                            "A higher boot ratio encourages the generation of images that are closely related to text \"hints\", often at the expense of reduced image quality"),
            gr.Textbox(label="Random seed",
                       placeholder="Random Seed",
                       lines=1),
        ],
        outputs=[
            gr.Gallery(label="Generated images")
        ])
        
interface = gr.Interface(
    predict,
    inputs="text",
    outputs="images",
    theme="huggingface",
    title="Among Us Logic AI Generator",
    description="Generate AI Images of Among Us characters in the Among Us Logic style!",
    article="<p style='text-align: center'>Among Us Logic AI Generator | Demo Model</p>",
    live=True,
)
interface.launch(share=True)

    return _app

app = run()
app.launch(debug=True)