KKNTRvol3 / app.py
KKNTR's picture
Update app.py
387f1c0 verified
import torch
from diffusers import StableDiffusionXLPipeline
import gradio as gr
import spaces
import random
model_id = "kkntr/sdxl-kkntr"
pipe = StableDiffusionXLPipeline.from_pretrained(
model_id,
torch_dtype=torch.float16,
use_safetensors=True
).to("cuda")
pipe.load_lora_weights(
{
"kkntr/lora1": 0.2,
"kkntr/lora2": 0.3,
"kkntr/lora12": 0.4,
"kkntr/lora10": 0.1,
}
)
pipe.fuse_lora()
resolutions = [
(592, 1768),
(608, 1696),
(640, 1624),
(672, 1544),
(720, 1440),
(744, 1392),
(784, 1320),
(832, 1248),
(864, 1208),
(880, 1184),
(912, 1144),
(976, 1072),
(1024, 1024),
(1072, 912),
(1144, 912),
(1184, 880),
(1208, 864),
(1248, 832),
(1320, 784),
(1392, 744),
(1440, 720),
(1544, 672),
(1624, 640),
(1696, 608),
(1768, 592),
]
lora_styles = {
"None": (None, 0.0, ""),
"Foreskin play": ("kkntr/lora5", 1.2, "foreskin insertion"),
"Cum through clothing": ("kkntr/lora6", 1.2, "cum in clothing"),
"Penis through leghole": ("kkntr/lora7", 9.0, "(((penis through leghole))), (loose shorts), (penis outline), poking out, genital outline, bulge flowing sideways along thigh, visible penis shape under fabric, tight crotch, fabric tension"),
"Frottage": ("kkntr/lora8", 1.2, "byfrottage, frottage"),
"Penis towards viewer": ("kkntr/lora9", 1.2, "penis_towards_viewer"),
"Foreskin play closeup": ("kkntr/lora11", 2.0, "ZonkFS"),
}
@spaces.GPU
def generate(prompt, negative_prompt, width, height, random_res, selected_style):
if random_res:
width, height = random.choice(resolutions)
# Valitaan tyyli-LoRA ja lisätään triggeri
lora_addition = {}
if selected_style != "None" and selected_style in lora_styles:
lora_path, lora_strength, lora_trigger = lora_styles[selected_style]
prompt = f"{lora_trigger}, {prompt}"
lora_addition[lora_path] = lora_strength
# Ladataan pysyvät + tyyli-LoRA yhteen
all_loras = {
"kkntr/lora1": 0.2,
"kkntr/lora2": 0.3,
"kkntr/lora12": 0.4,
"kkntr/lora10": 0.1,
}
all_loras.update(lora_addition) # ← MUUTETTU
pipe.load_lora_weights(all_loras) # ← MUUTETTU
pipe.fuse_lora() # ← MUUTETTU
quality_suffix = (
", (anthro), (male), (best quality), high resolution, (ultra detailed),"
" 8k, (highly detailed), (masterpiece), (sharp focus), (intricate details),"
" (perfect anatomy), (depth of field), high dynamic range,"
" (smooth shading), (realistic shadows), (rich texture),"
" professional color grading, (fine details), ultra sharp,"
" HDR, (anatomically correct), painterly realism, 20r0j_2, civifur"
)
full_prompt = prompt + quality_suffix
image = pipe(
prompt=full_prompt,
negative_prompt=negative_prompt,
width=width,
height=height,
num_inference_steps=35,
guidance_scale=7.5
).images[0]
return image, full_prompt
gr.Interface(
fn=generate,
inputs=[
gr.Textbox(label="Prompt"),
gr.Textbox(
label="Negative Prompt",
value="(worst quality), (low quality), (blurry), (bad anatomy), (fused fingers), (extra fingers), (missing fingers), (deformed), (jpeg artifacts), (watermark), (signature), text, error, out of frame, bad hands, bad feet, bad proportions, fused limbs, cropped, username, logo, bad perspective, lowres, overexposure, bad artist, bad composition, distorted, oversaturated, mutated, bad shadow, multiple limbs, extra arms, extra legs, bad background, tilted, bad lighting, bad face, ugly, bad eyes, disfigured, multiple pictures"
),
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Width"),
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Height"),
gr.Checkbox(label="Random resolution mode (override sliders)", value=True),
gr.Dropdown(
choices=list(lora_styles.keys()),
value="None",
label="Select Style"
)
],
outputs=[
gr.Image(label="Generated Image"),
gr.Textbox(label="Used Prompt", lines=4)
],
title="FURRYSTYLE",
description="Give a prompt"
).launch()