Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
from diffusers import StableDiffusionXLPipeline
|
| 3 |
import gradio as gr
|
| 4 |
-
import spaces
|
| 5 |
import random
|
|
|
|
| 6 |
|
| 7 |
model_id = "kkntr/sdxl-kkntr"
|
| 8 |
|
|
@@ -12,78 +13,41 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
| 12 |
use_safetensors=True
|
| 13 |
).to("cuda")
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
(784, 1320),
|
| 33 |
-
(832, 1248),
|
| 34 |
-
(864, 1208),
|
| 35 |
-
(880, 1184),
|
| 36 |
-
(912, 1144),
|
| 37 |
-
(976, 1072),
|
| 38 |
-
(1024, 1024),
|
| 39 |
-
(1072, 912),
|
| 40 |
-
(1144, 912),
|
| 41 |
-
(1184, 880),
|
| 42 |
-
(1208, 864),
|
| 43 |
-
(1248, 832),
|
| 44 |
-
(1320, 784),
|
| 45 |
-
(1392, 744),
|
| 46 |
-
(1440, 720),
|
| 47 |
-
(1544, 672),
|
| 48 |
-
(1624, 640),
|
| 49 |
-
(1696, 608),
|
| 50 |
-
(1768, 592),
|
| 51 |
-
]
|
| 52 |
-
|
| 53 |
-
lora_styles = {
|
| 54 |
-
"None": (None, 0.0, ""),
|
| 55 |
-
"Foreskin play": ("kkntr/lora5", 1.2, "foreskin insertion"),
|
| 56 |
-
"Cum through clothing": ("kkntr/lora6", 1.2, "cum in clothing"),
|
| 57 |
-
"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"),
|
| 58 |
-
"Frottage": ("kkntr/lora8", 1.2, "byfrottage, frottage"),
|
| 59 |
-
"Penis towards viewer": ("kkntr/lora9", 1.2, "penis_towards_viewer"),
|
| 60 |
-
"Foreskin play closeup": ("kkntr/lora11", 2.0, "ZonkFS"),
|
| 61 |
}
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
prompt = f"{lora_trigger}, {prompt}"
|
| 73 |
-
lora_addition[lora_path] = lora_strength
|
| 74 |
|
| 75 |
-
|
| 76 |
-
all_loras = {
|
| 77 |
-
"kkntr/lora1": 0.2,
|
| 78 |
-
"kkntr/lora2": 0.3,
|
| 79 |
-
"kkntr/lora12": 0.4,
|
| 80 |
-
"kkntr/lora10": 0.1,
|
| 81 |
-
}
|
| 82 |
-
all_loras.update(lora_addition) # ← MUUTETTU
|
| 83 |
-
|
| 84 |
-
pipe.load_lora_weights(all_loras) # ← MUUTETTU
|
| 85 |
-
pipe.fuse_lora() # ← MUUTETTU
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
quality_suffix = (
|
| 89 |
", (anthro), (male), (best quality), high resolution, (ultra detailed),"
|
|
@@ -107,27 +71,30 @@ def generate(prompt, negative_prompt, width, height, random_res, selected_style)
|
|
| 107 |
|
| 108 |
return image, full_prompt
|
| 109 |
|
|
|
|
| 110 |
gr.Interface(
|
| 111 |
fn=generate,
|
| 112 |
inputs=[
|
| 113 |
gr.Textbox(label="Prompt"),
|
| 114 |
gr.Textbox(
|
| 115 |
label="Negative Prompt",
|
| 116 |
-
value="(worst quality), (low quality), (blurry), (bad anatomy),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
),
|
| 118 |
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Width"),
|
| 119 |
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Height"),
|
| 120 |
-
gr.Checkbox(label="Random resolution mode (override sliders)", value=True),
|
| 121 |
-
gr.Dropdown(
|
| 122 |
-
choices=list(lora_styles.keys()),
|
| 123 |
-
value="None",
|
| 124 |
-
label="Select Style"
|
| 125 |
-
)
|
| 126 |
],
|
| 127 |
outputs=[
|
| 128 |
gr.Image(label="Generated Image"),
|
| 129 |
gr.Textbox(label="Used Prompt", lines=4)
|
| 130 |
],
|
| 131 |
-
title="FURRYSTYLE",
|
| 132 |
-
description="
|
| 133 |
-
).launch()
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
import torch
|
| 3 |
from diffusers import StableDiffusionXLPipeline
|
| 4 |
import gradio as gr
|
|
|
|
| 5 |
import random
|
| 6 |
+
import re
|
| 7 |
|
| 8 |
model_id = "kkntr/sdxl-kkntr"
|
| 9 |
|
|
|
|
| 13 |
use_safetensors=True
|
| 14 |
).to("cuda")
|
| 15 |
|
| 16 |
+
# Scratchpad-listat
|
| 17 |
+
scratchpads = {
|
| 18 |
+
"kuvakulma": [
|
| 19 |
+
"close-up shot",
|
| 20 |
+
"overhead view",
|
| 21 |
+
"wide-angle perspective",
|
| 22 |
+
"low angle",
|
| 23 |
+
"high angle",
|
| 24 |
+
"from behind",
|
| 25 |
+
],
|
| 26 |
+
"valaistus": [
|
| 27 |
+
"cinematic lighting",
|
| 28 |
+
"soft studio light",
|
| 29 |
+
"backlit",
|
| 30 |
+
"dramatic shadows",
|
| 31 |
+
"neon glow",
|
| 32 |
+
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
+
def expand_scratchpad_tags(prompt: str) -> str:
|
| 36 |
+
"""
|
| 37 |
+
Korvaa [tagi] scratchpad-listasta satunnaisella vaihtoehdolla.
|
| 38 |
+
"""
|
| 39 |
+
def replacer(match):
|
| 40 |
+
tag = match.group(1)
|
| 41 |
+
if tag in scratchpads:
|
| 42 |
+
return random.choice(scratchpads[tag])
|
| 43 |
+
return match.group(0) # jätä koskematta jos ei löydy
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
return re.sub(r"\[([a-zA-Z0-9_]+)\]", replacer, prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
@spaces.GPU
|
| 48 |
+
def generate(prompt, negative_prompt, width, height):
|
| 49 |
+
# Korvataan scratchpad-tagit ennen kuin prompt menee pipeen
|
| 50 |
+
prompt = expand_scratchpad_tags(prompt)
|
| 51 |
|
| 52 |
quality_suffix = (
|
| 53 |
", (anthro), (male), (best quality), high resolution, (ultra detailed),"
|
|
|
|
| 71 |
|
| 72 |
return image, full_prompt
|
| 73 |
|
| 74 |
+
# Gradio UI
|
| 75 |
gr.Interface(
|
| 76 |
fn=generate,
|
| 77 |
inputs=[
|
| 78 |
gr.Textbox(label="Prompt"),
|
| 79 |
gr.Textbox(
|
| 80 |
label="Negative Prompt",
|
| 81 |
+
value="(worst quality), (low quality), (blurry), (bad anatomy), "
|
| 82 |
+
"(fused fingers), (extra fingers), (missing fingers), "
|
| 83 |
+
"(deformed), (jpeg artifacts), (watermark), (signature), "
|
| 84 |
+
"text, error, out of frame, bad hands, bad feet, bad proportions, "
|
| 85 |
+
"fused limbs, cropped, username, logo, bad perspective, "
|
| 86 |
+
"lowres, overexposure, bad artist, bad composition, "
|
| 87 |
+
"distorted, oversaturated, mutated, bad shadow, multiple limbs, "
|
| 88 |
+
"extra arms, extra legs, bad background, tilted, bad lighting, "
|
| 89 |
+
"bad face, ugly, bad eyes, disfigured, multiple pictures"
|
| 90 |
),
|
| 91 |
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Width"),
|
| 92 |
gr.Slider(minimum=512, maximum=1024, step=64, value=768, label="Height"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
],
|
| 94 |
outputs=[
|
| 95 |
gr.Image(label="Generated Image"),
|
| 96 |
gr.Textbox(label="Used Prompt", lines=4)
|
| 97 |
],
|
| 98 |
+
title="FURRYSTYLE Scratchpad",
|
| 99 |
+
description="Käytä [kuvakulma] tai [valaistus] tageja promptissa, niin ne täytetään satunnaisesti."
|
| 100 |
+
).launch()
|