Spaces:
Runtime error
Runtime error
File size: 952 Bytes
518b305 caae6ea 518b305 |
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 |
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
# Modelo base
modelo_base = "runwayml/stable-diffusion-v1-5" # Puedes cambiarlo si usas otro modelo compatible
# Cargar el pipeline
pipe = StableDiffusionPipeline.from_pretrained(
modelo_base,
torch_dtype=torch.float16
).to("cpu")
# Cargar LoRA (ajusta a tu ruta)
pipe.load_lora_weights("DRDELATV/lora-image-caricature", weight_name="JNX_Funny_Caricature (1).safetensors")
# Función para generar la imagen
def generar(prompt):
image = pipe(prompt).images[0]
return image
# Interfaz con Gradio
demo = gr.Interface(
fn=generar,
inputs=gr.Textbox(label="Prompt de entrada", placeholder="Describe la imagen que quieres..."),
outputs=gr.Image(type="pil", label="Imagen generada"),
title="Generador de caricaturas con LoRA",
description="Este generador usa Stable Diffusion + LoRA para crear imágenes caricaturescas."
)
demo.launch()
|