File size: 2,256 Bytes
f968273
 
38f04e3
f968273
38f04e3
 
 
 
 
 
4f68e5e
38f04e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f968273
38f04e3
 
f968273
38f04e3
f968273
38f04e3
 
 
f968273
 
 
38f04e3
 
 
f968273
38f04e3
f968273
38f04e3
 
 
 
f968273
 
38f04e3
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import gradio as gr
import numpy as np
from PIL import Image, ImageDraw

def undress_image(image, penis_size):
    # Convert the image to PIL if it's a numpy array or file path
    if isinstance(image, str):
        img = Image.open(image)
    elif isinstance(image, np.ndarray):
        img = Image.fromarray(image)
    else:
        raise ValueError("Unsupported image type")
    
    # Convert to RGB if necessary
    if img.mode != 'RGB':
        img = img.convert('RGB')
    
    # For simulation: we'll draw a rectangle in the lower middle part of the image
    # The size of the rectangle will depend on the choice
    draw = ImageDraw.Draw(img)
    width, height = img.size
    
    # Define rectangle dimensions based on choice
    if penis_size == "Small":
        rect_height = height // 10
        rect_width = width // 15
    else:  # Large
        rect_height = height // 6
        rect_width = width // 8
    
    # Position: centered horizontally, near the bottom
    left = (width - rect_width) // 2
    top = height - rect_height - 20  # 20 pixels from bottom
    right = left + rect_width
    bottom = top + rect_height
    
    # Draw a rectangle (in red for simulation, but in reality you'd use skin tone or inpainting)
    draw.rectangle([left, top, right, bottom], fill="red")
    
    # Convert back to numpy array for Gradio
    return np.array(img)

# Gradio app
with gr.Blocks() as demo:
    gr.Markdown("# Male Undressing App")
    gr.Markdown("Upload a male photo and choose the penis size for the generated image. This app is for personal use only.")
    gr.Markdown("Built with [anycoder](https://huggingface.co/spaces/akhaliq/anycoder)")
    
    with gr.Row():
        with gr.Column():
            image_input = gr.Image(type="filepath", label="Upload Photo")
            size_choice = gr.Radio(choices=["Small", "Large"], label="Penis Size", value="Small")
            button = gr.Button("Generate Undressed Image")
        with gr.Column():
            image_output = gr.Image(label="Result")
    
    button.click(
        fn=undress_image,
        inputs=[image_input, size_choice],
        outputs=image_output
    )

# Launch with a theme and other parameters in the launch method
demo.launch(theme=gr.themes.Soft())