File size: 1,130 Bytes
8645d45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b075ba0
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
import torch
from diffusers import AutoPipelineForText2Image
import gradio as gr
import peft

MODEL_NAME = "stabilityai/sdxl-turbo"

pipe = AutoPipelineForText2Image.from_pretrained(MODEL_NAME, torch_dtype=torch.float16, variant="fp16")
pipe.to("cuda")

pipe.load_lora_weights("AbdalrhmanRi/SDXL-Turbo-With-AppleVisionPro", weight_name="pytorch_lora_weights.safetensors")

def generate_image(prompt):
    image = pipe(prompt=prompt, guidance_scale=2.0, num_inference_steps=40, height=480)
    image = image.images[0]

    yield image, None

    refiner_image = pipe(prompt=prompt, image=image, guidance_scale=1.0, height=480)
    refiner_image = refiner_image.images[0]

    yield image, refiner_image


# Set up the Gradio interface
interface = gr.Interface(
    fn=generate_image,
    inputs=gr.components.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
    outputs=[gr.Image(type="pil", label="Generated Image"), gr.Image(type="pil", label="Refined Image")],
    title="Generate Image Using Generative AI",
    theme=gr.themes.Default(primary_hue="green")
)

# Launch the interface
interface.launch()