|
import gradio as gr |
|
import torch |
|
from diffusers import StableDiffusionPipeline, AutoencoderKL |
|
|
|
|
|
NEGATIVE_PROMPT = ( |
|
"blurry, low quality, lowres, bad anatomy, bad proportions, deformed, distorted, disfigured, mutated, " |
|
"missing limbs, extra limbs, bad hands, fused fingers, missing fingers, bad feet, flat feet, fused toes, " |
|
"bad legs, short legs, long arms, malformed body, asymmetric body, unnatural pose, broken limbs, bad perspective, " |
|
"unnatural expression, strange eyes, cross-eyed, lazy eye, extra eyes, fused eyes, one eye, bad eyes, bad face, " |
|
"multiple faces, deformed face, mutated face, distorted face, ugly face, pale skin, unrealistic skin, overexposed, " |
|
"underexposed, high contrast, jpeg artifacts, watermark, text, logo, signature, cropped, cartoon, anime, sketch, painting" |
|
) |
|
|
|
|
|
device = "cuda" if torch.cuda.is_available() else "cpu" |
|
dtype = torch.float16 if torch.cuda.is_available() else torch.float32 |
|
|
|
|
|
pipe = StableDiffusionPipeline.from_pretrained( |
|
"SG161222/Realistic_Vision_V6.0_B1_noVAE", |
|
torch_dtype=dtype, |
|
safety_checker=None |
|
).to(device) |
|
|
|
|
|
pipe.vae = AutoencoderKL.from_pretrained( |
|
"stabilityai/sd-vae-ft-mse", |
|
torch_dtype=dtype |
|
).to(device) |
|
|
|
|
|
try: |
|
pipe.load_lora_weights("DRDELATV/Woman_Asiatic_Defi") |
|
pipe.set_adapters(["default_0"], adapter_weights=[1.0]) |
|
except Exception as e: |
|
print("Error cargando LoRA:", e) |
|
|
|
|
|
def generar(prompt, steps, scale): |
|
image = pipe( |
|
prompt, |
|
negative_prompt=NEGATIVE_PROMPT, |
|
num_inference_steps=steps, |
|
guidance_scale=scale |
|
).images[0] |
|
return image |
|
|
|
|
|
gr.Interface( |
|
fn=generar, |
|
inputs=[ |
|
gr.Textbox(label="Escribe el promt de tu modelo"), |
|
gr.Slider(20, 100, value=50, step=5, label="Inference Steps"), |
|
gr.Slider(1.0, 15.0, value=5.5, step=0.5, label="Guidance Scale") |
|
], |
|
outputs=gr.Image(label="Imagen generada"), |
|
title="Generador Woman x Global", |
|
description="-------------------------------------------------------------------------", |
|
).launch() |
|
|