File size: 1,772 Bytes
3f82dd2
2d2a069
3f82dd2
 
fb5e5fd
860b46c
 
ed74e1d
fb5e5fd
 
 
860b46c
3f82dd2
fb5e5fd
860b46c
 
 
 
 
 
 
fb5e5fd
860b46c
 
 
 
2d2a069
 
fb5e5fd
2d2a069
 
 
fb5e5fd
 
 
 
 
 
 
 
 
 
 
 
2d2a069
 
 
ed74e1d
2d2a069
cd0d0e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import gradio as gr
from diffusers import StableDiffusionImg2ImgPipeline
import torch

# فقط CPU + float32 + بدون LoRA + مدل کوچک‌تر
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float32,
    safety_checker=None,
    variant="fp16",  # مدل کوچیک‌تر
    use_safetensors=True
)

def generate(image, prompt, negative_prompt="", steps=15, strength=0.35):
    try:
        result = pipe(
            prompt=prompt,
            negative_prompt=negative_prompt,
            image=image,
            num_inference_steps=steps,
            strength=strength,
            guidance_scale=7.0
        ).images[0]
        return result
    except Exception as e:
        return f"Error: {str(e)}"

with gr.Blocks() as demo:
    gr.Markdown("## NSFW Face Swap (CPU Only - No LoRA)")
    with gr.Row():
        with gr.Column():
            input_img = gr.Image(type="pil", label="Upload Face Photo")
            prompt = gr.Textbox(
                label="Prompt", 
                lines=3, 
                value="photorealistic, nude girl sitting on bed, wearing tiny lace thong, small pink vulva visible, wet, face locked to input image"
            )
            neg_prompt = gr.Textbox(
                label="Negative", 
                value="large vulva, deformed, plastic, child, extra limbs"
            )
            steps = gr.Slider(10, 25, 15, label="Steps (کم = سریع‌تر)")
            strength = gr.Slider(0.2, 0.5, 0.35, label="Strength")
            btn = gr.Button("Generate (20-40s)")
        with gr.Column():
            output = gr.Image(label="Result")
    
    btn.click(generate, [input_img, prompt, neg_prompt, steps, strength], output)

demo.launch()