File size: 1,190 Bytes
433982d
95fee85
433982d
35e3eb3
 
 
 
 
3f1dec5
35e3eb3
 
 
3f1dec5
 
35e3eb3
 
 
3f1dec5
35e3eb3
95fee85
35e3eb3
 
 
 
a143a22
 
 
 
3a5ac9b
a31e26c
a143a22
 
 
 
 
3f1dec5
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
import gradio as gr
import spaces

#gr.load("models/sergon19/green_bg_LoRa10").launch()

import torch
from diffusers import DiffusionPipeline, AutoencoderKL

vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True
)
pipe.load_lora_weights("sergon19/green_bg_LoRa10")
_ = pipe.to("cuda")

@spaces.GPU
def generate_image(prompt):
    image = pipe(prompt=prompt, num_inference_steps=25).images[0]
    return image

# Adding examples to the Gradio interface
examples = [
    ["A serene landscape with mountains and a river in sgc style"],
    ["A futuristic city skyline at night in sgc style"],
    ["a busy wallstreet office in sgc style"],
    ["A beach scene with a pirate ship visible in the ocean in sgc style"],
    ["A vibrant underwater scene with coral reefs and fish in sgc style"],
    ["A magical forest with glowing plants and creatures in sgc style"],
]

iface = gr.Interface(fn=generate_image, inputs="text", outputs="image", examples=examples)
iface.launch()