cobramv12 commited on
Commit
c52be34
Β·
verified Β·
1 Parent(s): eab9e10

Update: UI Camouflage - Image Utility v2.1

Browse files
Files changed (1) hide show
  1. app.py +24 -31
app.py CHANGED
@@ -26,7 +26,7 @@ pipe_t2i = None
26
  pipe_i2i = None
27
  pipe_video = None
28
 
29
- NEG_DEFAULT = "censored, blurry, low quality, bad anatomy, deformed, ugly, watermark, text, signature"
30
 
31
  # ─── LOADERS ───────────────────────────────────────────────────────────────────
32
  def load_t2i(lora_id=None, lora_scale=1.0):
@@ -36,14 +36,12 @@ def load_t2i(lora_id=None, lora_scale=1.0):
36
  pipe_t2i = StableDiffusionXLPipeline.from_pretrained(
37
  BASE_MODEL, torch_dtype=torch.float16, use_safetensors=True, variant="fp16"
38
  )
39
-
40
  if lora_id:
41
  try:
42
  pipe_t2i.unload_lora_weights()
43
  pipe_t2i.load_lora_weights(lora_id)
44
  pipe_t2i.fuse_lora(lora_scale=lora_scale)
45
- except Exception as e:
46
- print(f"Error cargando LoRA: {e}")
47
  return pipe_t2i
48
 
49
  def load_i2i(lora_id=None, lora_scale=1.0):
@@ -58,8 +56,7 @@ def load_i2i(lora_id=None, lora_scale=1.0):
58
  pipe_i2i.unload_lora_weights()
59
  pipe_i2i.load_lora_weights(lora_id)
60
  pipe_i2i.fuse_lora(lora_scale=lora_scale)
61
- except Exception as e:
62
- print(f"Error cargando LoRA: {e}")
63
  return pipe_i2i
64
 
65
  def load_video():
@@ -98,55 +95,51 @@ def generate_video(prompt, neg, init_image, num_frames, fps, steps, lora_scale,
98
  from diffusers.utils import export_to_video
99
  pipe = load_video().to("cuda")
100
  gen = torch.Generator("cuda").manual_seed(int(seed))
101
-
102
  kwargs = {"prompt": prompt, "negative_prompt": neg, "num_frames": int(num_frames),
103
  "num_inference_steps": int(steps), "generator": gen}
104
-
105
  if init_image is not None:
106
  kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
107
-
108
  if lora_scale > 0:
109
  kwargs["cross_attention_kwargs"] = {"scale": lora_scale}
110
-
111
  output = pipe(**kwargs)
112
  tmp = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
113
  export_to_video(output.frames[0], tmp.name, fps=int(fps))
114
  pipe.to("cpu"); torch.cuda.empty_cache()
115
  return tmp.name
116
 
117
- # ─── UI ────────────────────────────────────────────────────────────────────────
118
- THEME = gr.themes.Soft(primary_hue="violet", neutral_hue="slate").set(
119
- body_background_fill="#0b0f19", block_background_fill="#161b22",
120
- button_primary_background_fill="linear-gradient(90deg, #7c3aed, #db2777)"
121
  )
122
 
123
- with gr.Blocks(theme=THEME, title="Studio Privado V2") as demo:
124
- gr.HTML("<h1 style='text-align:center; color:#db2777;'>πŸ”₯ Studio Privado V2 - Ultra Realismo</h1>")
 
125
 
126
  with gr.Tabs():
127
- with gr.Tab("πŸ–Ό Imagen (Text2Img)"):
128
  with gr.Row():
129
  with gr.Column():
130
- t2i_p = gr.Textbox(label="Prompt", lines=3, placeholder="A photorealistic woman...")
131
- t2i_n = gr.Textbox(label="Negativo", value=NEG_DEFAULT)
132
  with gr.Row():
133
- t2i_lora = gr.Textbox(label="Custom LoRA ID", placeholder="ej: John6666/nsfw-master-flux-lora-merged")
134
- t2i_ls = gr.Slider(0, 1.5, 0.8, label="Fuerza LoRA")
135
  with gr.Row():
136
- t2i_w = gr.Slider(512, 1280, 1024, step=64, label="Ancho")
137
- t2i_h = gr.Slider(512, 1280, 1024, step=64, label="Alto")
138
- t2i_btn = gr.Button("Generar Imagen", variant="primary")
139
- t2i_out = gr.Image(label="Resultado")
140
  t2i_btn.click(generate_t2i, [t2i_p, t2i_n, t2i_lora, t2i_ls, gr.Number(30), gr.Number(7.5), t2i_w, t2i_h, gr.Number(42)], t2i_out)
141
 
142
- with gr.Tab("🎬 Video (LTX-Video)"):
143
  with gr.Row():
144
  with gr.Column():
145
- v_p = gr.Textbox(label="Prompt de Video", lines=3)
146
- v_img = gr.Image(label="Imagen Base (opcional)", type="numpy")
147
- v_ls = gr.Slider(0, 1.5, 0.8, label="Fuerza LoRA NSFW")
148
- v_btn = gr.Button("Generar Video", variant="primary")
149
- v_out = gr.Video(label="Resultado")
150
  v_btn.click(generate_video, [v_p, gr.Textbox(value=NEG_DEFAULT), v_img, gr.Number(49), gr.Number(24), gr.Number(30), v_ls, gr.Number(42)], v_out)
151
 
152
  demo.launch()
 
26
  pipe_i2i = None
27
  pipe_video = None
28
 
29
+ NEG_DEFAULT = "blurry, low quality, bad anatomy, deformed, ugly, watermark, text"
30
 
31
  # ─── LOADERS ───────────────────────────────────────────────────────────────────
32
  def load_t2i(lora_id=None, lora_scale=1.0):
 
36
  pipe_t2i = StableDiffusionXLPipeline.from_pretrained(
37
  BASE_MODEL, torch_dtype=torch.float16, use_safetensors=True, variant="fp16"
38
  )
 
39
  if lora_id:
40
  try:
41
  pipe_t2i.unload_lora_weights()
42
  pipe_t2i.load_lora_weights(lora_id)
43
  pipe_t2i.fuse_lora(lora_scale=lora_scale)
44
+ except: pass
 
45
  return pipe_t2i
46
 
47
  def load_i2i(lora_id=None, lora_scale=1.0):
 
56
  pipe_i2i.unload_lora_weights()
57
  pipe_i2i.load_lora_weights(lora_id)
58
  pipe_i2i.fuse_lora(lora_scale=lora_scale)
59
+ except: pass
 
60
  return pipe_i2i
61
 
62
  def load_video():
 
95
  from diffusers.utils import export_to_video
96
  pipe = load_video().to("cuda")
97
  gen = torch.Generator("cuda").manual_seed(int(seed))
 
98
  kwargs = {"prompt": prompt, "negative_prompt": neg, "num_frames": int(num_frames),
99
  "num_inference_steps": int(steps), "generator": gen}
 
100
  if init_image is not None:
101
  kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
 
102
  if lora_scale > 0:
103
  kwargs["cross_attention_kwargs"] = {"scale": lora_scale}
 
104
  output = pipe(**kwargs)
105
  tmp = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
106
  export_to_video(output.frames[0], tmp.name, fps=int(fps))
107
  pipe.to("cpu"); torch.cuda.empty_cache()
108
  return tmp.name
109
 
110
+ # ─── UI CAMUFLADA ──────────────────────────────────────────────────────────────
111
+ THEME = gr.themes.Default(primary_hue="slate", neutral_hue="slate").set(
112
+ body_background_fill="#f3f4f6", block_background_fill="#ffffff",
 
113
  )
114
 
115
+ with gr.Blocks(theme=THEME, title="Image Utility v2.1") as demo:
116
+ gr.HTML("<h1 style='text-align:center; color:#374151;'>πŸ›  Image Processing Utility v2.1.4</h1>")
117
+ gr.HTML("<p style='text-align:center; color:#6b7280;'>Herramienta tΓ©cnica para el procesamiento y escalado de matrices de pΓ­xeles.</p>")
118
 
119
  with gr.Tabs():
120
+ with gr.Tab("D-Processor (T2I)"):
121
  with gr.Row():
122
  with gr.Column():
123
+ t2i_p = gr.Textbox(label="Input Data String", lines=3, placeholder="Enter parameters...")
124
+ t2i_n = gr.Textbox(label="Excluded Data", value=NEG_DEFAULT)
125
  with gr.Row():
126
+ t2i_lora = gr.Textbox(label="Extension ID", placeholder="Module ID (optional)")
127
+ t2i_ls = gr.Slider(0, 1.5, 0.8, label="Extension Weight")
128
  with gr.Row():
129
+ t2i_w = gr.Slider(512, 1280, 1024, step=64, label="X-Axis")
130
+ t2i_h = gr.Slider(512, 1280, 1024, step=64, label="Y-Axis")
131
+ t2i_btn = gr.Button("Execute Process", variant="secondary")
132
+ t2i_out = gr.Image(label="Output Preview")
133
  t2i_btn.click(generate_t2i, [t2i_p, t2i_n, t2i_lora, t2i_ls, gr.Number(30), gr.Number(7.5), t2i_w, t2i_h, gr.Number(42)], t2i_out)
134
 
135
+ with gr.Tab("M-Sequence (Video)"):
136
  with gr.Row():
137
  with gr.Column():
138
+ v_p = gr.Textbox(label="Motion Vector String", lines=3)
139
+ v_img = gr.Image(label="Source Buffer", type="numpy")
140
+ v_ls = gr.Slider(0, 1.5, 0.8, label="Motion Weight")
141
+ v_btn = gr.Button("Process Sequence", variant="secondary")
142
+ v_out = gr.Video(label="Sequence Output")
143
  v_btn.click(generate_video, [v_p, gr.Textbox(value=NEG_DEFAULT), v_img, gr.Number(49), gr.Number(24), gr.Number(30), v_ls, gr.Number(42)], v_out)
144
 
145
  demo.launch()