Spaces:
Runtime error
Runtime error
File size: 1,551 Bytes
429be58 47d9d40 429be58 e5f23f6 47d9d40 e5f23f6 0331ba4 47d9d40 e5f23f6 47d9d40 e5f23f6 |
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 |
import gradio as gr
import torch
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import make_image_grid, load_image
# gr.load("models/NSTiwari/SDXL_LoRA_model").launch()
pipeline = AutoPipelineForImage2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
pipeline.load_lora_weights('pytorch_lora_weights_00.safetensors')
# _ = pipeline.to("cuda")
pipeline.enable_model_cpu_offload()
url = "https://img.onmanorama.com/content/dam/mm/en/lifestyle/decor/images/2020/12/1/25-lakh-living-hall.jpg.transform/576x300/image.jpg"
# init_image = load_image(url)
# image = init_image.resize((1024, 576))
prompt = "A cozy Indian living room glows with morning sunshine on Republic Day, its walls decked in saffron, white, and green tapestries and art, while colorful cushions and festive garlands add a vibrant, celebratory air."
# pass prompt and image to pipeline
image_out = pipeline(prompt, image=image, strength=0.5).images[0]
# make_image_grid([image, image_out], rows=1, cols=2)
# Define the image generation function
def generate_image(prompt, image_url):
init_image = load_image(image_url)
image = init_image.resize((1024, 576))
image_out = pipeline(prompt, image=image, strength=0.5).images[0]
return image_out
# Set up Gradio interface
iface = gr.Interface(
fn=generate_image,
inputs=[gr.Textbox(label="Prompt"), gr.Textbox(label="Image URL")],
outputs="image"
)
# Launch the Gradio app
iface.launch() |