File size: 1,171 Bytes
0cfda91
 
 
 
66a8ad0
 
0cfda91
 
 
 
 
 
66a8ad0
 
 
 
e05c142
66a8ad0
 
 
 
 
 
 
 
 
0cfda91
 
 
 
66a8ad0
7005662
66a8ad0
 
0cfda91
 
 
 
 
 
 
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
import gradio as gr
import torch
import requests
from torchvision import transforms
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler, EulerDiscreteScheduler


model = torch.hub.load("pytorch/vision:v0.6.0", "resnet18", pretrained=True).eval()
response = requests.get("https://git.io/JJkYN")
labels = response.text.split("\n")


def generate(inp):
    torch.cuda.empty_cache()
    print(f"Is CUDA available: {torch.cuda.is_available()}")

    pipeline = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
    
    #pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)
    #another comment
    pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)
    
    pipeline = pipeline.to("cuda")
    image = pipeline(inp, height=512, width=512).images[0]

    return image


def run():
    demo = gr.Interface(
        fn=generate,
        inputs=gr.inputs.Textbox(label="Prompt"),
        outputs=gr.outputs.Image(type="pil"),
        
    )

    demo.launch(server_name="0.0.0.0", server_port=7860)


if __name__ == "__main__":
    run()