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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -2,17 +2,16 @@ import gradio as gr
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,
@@ -20,22 +19,29 @@ def generate(image, prompt, negative_prompt="", steps=20, strength=0.3, cfg=7.0)
20
  image=image,
21
  num_inference_steps=steps,
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
 
 
2
  from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
 
5
+ # فقط CPU + float32 + بدون LoRA + مدل کوچک‌تر
6
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
7
  "runwayml/stable-diffusion-v1-5",
8
  torch_dtype=torch.float32,
9
+ safety_checker=None,
10
+ variant="fp16", # مدل کوچیک‌تر
11
+ use_safetensors=True
12
  )
13
 
14
+ def generate(image, prompt, negative_prompt="", steps=15, strength=0.35):
 
 
 
15
  try:
16
  result = pipe(
17
  prompt=prompt,
 
19
  image=image,
20
  num_inference_steps=steps,
21
  strength=strength,
22
+ guidance_scale=7.0
23
  ).images[0]
24
  return result
25
  except Exception as e:
26
  return f"Error: {str(e)}"
27
 
28
  with gr.Blocks() as demo:
29
+ gr.Markdown("## NSFW Face Swap (CPU Only - No LoRA)")
30
  with gr.Row():
31
  with gr.Column():
32
  input_img = gr.Image(type="pil", label="Upload Face Photo")
33
+ prompt = gr.Textbox(
34
+ label="Prompt",
35
+ lines=3,
36
+ value="photorealistic, nude girl sitting on bed, wearing tiny lace thong, small pink vulva visible, wet, face locked to input image"
37
+ )
38
+ neg_prompt = gr.Textbox(
39
+ label="Negative",
40
+ value="large vulva, deformed, plastic, child, extra limbs"
41
+ )
42
+ steps = gr.Slider(10, 25, 15, label="Steps (کم = سریع‌تر)")
43
+ strength = gr.Slider(0.2, 0.5, 0.35, label="Strength")
44
+ btn = gr.Button("Generate (20-40s)")
45
  with gr.Column():
46
  output = gr.Image(label="Result")
47