Mbeheshtii commited on
Commit
ed74e1d
·
verified ·
1 Parent(s): 860b46c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -18
app.py CHANGED
@@ -2,19 +2,18 @@ import gradio as gr
2
  from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
 
5
- # فقط CPU
6
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
7
  "runwayml/stable-diffusion-v1-5",
8
- torch_dtype=torch.float32, # float16 روی CPU نمی‌شه
9
- safety_checker=None,
10
- requires_safety_checker=False
11
  )
12
 
13
- def generate(image, prompt, negative_prompt="", steps=20, strength=0.3, cfg=7.0, lora_path=None, lora_strength=0.6):
 
 
 
14
  try:
15
- if lora_path:
16
- pipe.load_lora_weights(lora_path)
17
-
18
  result = pipe(
19
  prompt=prompt,
20
  negative_prompt=negative_prompt,
@@ -23,26 +22,23 @@ def generate(image, prompt, negative_prompt="", steps=20, strength=0.3, cfg=7.0,
23
  strength=strength,
24
  guidance_scale=cfg
25
  ).images[0]
26
-
27
  return result
28
  except Exception as e:
29
  return f"Error: {str(e)}"
30
 
31
  with gr.Blocks() as demo:
32
- gr.Markdown("## NSFW Image-to-Image (CPU Only)")
33
  with gr.Row():
34
  with gr.Column():
35
  input_img = gr.Image(type="pil", label="Upload Face Photo")
36
- prompt = gr.Textbox(label="Prompt", lines=3, value="nude girl in bedroom, wearing tiny lace thong, small vulva visible, face locked to input image")
37
- neg_prompt = gr.Textbox(label="Negative", value="deformed, large vulva, child")
38
- steps = gr.Slider(10, 30, 20, label="Steps (کم = سریع‌تر)")
39
- strength = gr.Slider(0.1, 0.5, 0.3, label="Strength")
40
- cfg = gr.Slider(5, 10, 7.0, label="CFG")
41
- lora_file = gr.File(label="Upload LoRA")
42
- btn = gr.Button("Generate (30–60s)")
43
  with gr.Column():
44
  output = gr.Image(label="Result")
45
 
46
- btn.click(generate, [input_img, prompt, neg_prompt, steps, strength, cfg, lora_file], output)
47
 
48
  demo.launch()
 
2
  from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
 
5
+ # Load model
6
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
7
  "runwayml/stable-diffusion-v1-5",
8
+ torch_dtype=torch.float32,
9
+ safety_checker=None
 
10
  )
11
 
12
+ # Load LoRA directly from file (no upload needed)
13
+ pipe.load_lora_weights("Grool LORA.safetensors")
14
+
15
+ def generate(image, prompt, negative_prompt="", steps=20, strength=0.3, cfg=7.0):
16
  try:
 
 
 
17
  result = pipe(
18
  prompt=prompt,
19
  negative_prompt=negative_prompt,
 
22
  strength=strength,
23
  guidance_scale=cfg
24
  ).images[0]
 
25
  return result
26
  except Exception as e:
27
  return f"Error: {str(e)}"
28
 
29
  with gr.Blocks() as demo:
30
+ gr.Markdown("## NSFW Face Swap (LoRA Built-in)")
31
  with gr.Row():
32
  with gr.Column():
33
  input_img = gr.Image(type="pil", label="Upload Face Photo")
34
+ prompt = gr.Textbox(label="Prompt", lines=3, value="photorealistic, nude girl on bed, tiny lace thong, small pink vulva visible, wet, face locked to input image")
35
+ neg_prompt = gr.Textbox(label="Negative", value="large vulva, deformed, plastic, child")
36
+ steps = gr.Slider(15, 30, 20, label="Steps")
37
+ strength = gr.Slider(0.2, 0.5, 0.3, label="Strength")
38
+ btn = gr.Button("Generate (30-60s)")
 
 
39
  with gr.Column():
40
  output = gr.Image(label="Result")
41
 
42
+ btn.click(generate, [input_img, prompt, neg_prompt, steps, strength], output)
43
 
44
  demo.launch()