File size: 2,541 Bytes
66b0cef
160cf01
66b0cef
e816365
 
8a42a65
5808f1f
 
 
bce0716
76ea01b
 
 
 
 
 
 
b060071
76ea01b
 
b060071
 
76ea01b
147944d
76ea01b
 
 
 
147944d
bce0716
76ea01b
b060071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76ea01b
 
 
 
 
73a0c03
 
 
b060071
 
73a0c03
b060071
76ea01b
 
b060071
73a0c03
 
cc9c757
160cf01
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import gradio as gr
import random

# Load the model
model = gr.load("models/Purz/face-projection")

def generate_image(text, seed):
    if seed is not None:
        random.seed(seed)

    # Define slight variations of the original prompt for different poses/positions
    variations = [
        f"{text}, front view",
        f"{text}, side view",
        f"{text}, dynamic pose",
        f"{text}, close-up view"
    ]

    # Generate an image for each variation
    images = [model(variation) for variation in variations]
    return images

# Define examples with pre-generated image previews
examples = [
    ["Humanoid Cat Warrior, Full View", None, "path/to/humanoid_cat_preview.jpg"],
    ["Warhammer Sisterhood", None, "path/to/warhammer_sisterhood_preview.jpg"],
    ["Future Robots war", None, "path/to/future_robots_war_preview.jpg"],
    ["Fantasy dragon", None, "path/to/fantasy_dragon_preview.jpg"]
]

# Custom CSS for styling
css = """
/* General button styles */
button {
    border-radius: 25px; /* Capsule shape */
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #6D5BBA, #8A2387); /* Gradient color */
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

button:hover {
    background: linear-gradient(135deg, #8A2387, #6D5BBA); /* Gradient reverse on hover */
}

/* Slider handle style */
input[type=range] {
    accent-color: #8A2387; /* Gradient color accent */
}

/* Textbox styling */
.gr-textbox {
    border-radius: 8px;
    border: 1px solid #DDD;
    padding: 10px;
}

/* Output image styling */
.output_image {
    border: 2px solid #6D5BBA;
    border-radius: 10px;
    padding: 10px;
    background-color: #f9f9f9;
}
"""

# Define a function to create the examples with preview images
def create_example_row(example):
    return [gr.Example(value=example[0], examples=None, label=example[0], image=example[2])]

# Gradio interface
interface = gr.Interface(
    fn=generate_image,
    inputs=[
        gr.Textbox(label="Type your imagination:", placeholder="Type or select an example..."),
        gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
    ],
    outputs=[gr.Image(label=f"Generated Image {i+1}") for i in range(4)],
    examples=create_example_row(examples),  # Use pre-generated images for previews
    css=css,
    description="Note: The model is running on CPU; processing might take a bit longer. Thank you for your patience!"
)

# Launch the interface
interface.launch()