KKNTR commited on
Commit
b3bc4b4
·
verified ·
1 Parent(s): 38f0c8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -79
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
- pipe.load_lora_weights(
16
- {
17
- "kkntr/lora1": 0.2,
18
- "kkntr/lora2": 0.3,
19
- "kkntr/lora12": 0.4,
20
- "kkntr/lora10": 0.1,
21
- }
22
- )
23
- pipe.fuse_lora()
24
-
25
- resolutions = [
26
- (592, 1768),
27
- (608, 1696),
28
- (640, 1624),
29
- (672, 1544),
30
- (720, 1440),
31
- (744, 1392),
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
- @spaces.GPU
64
- def generate(prompt, negative_prompt, width, height, random_res, selected_style):
65
- if random_res:
66
- width, height = random.choice(resolutions)
67
-
68
- # Valitaan tyyli-LoRA ja lisätään triggeri
69
- lora_addition = {}
70
- if selected_style != "None" and selected_style in lora_styles:
71
- lora_path, lora_strength, lora_trigger = lora_styles[selected_style]
72
- prompt = f"{lora_trigger}, {prompt}"
73
- lora_addition[lora_path] = lora_strength
74
 
75
- # Ladataan pysyvät + tyyli-LoRA yhteen
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), (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"
 
 
 
 
 
 
 
 
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="Give a prompt"
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()