File size: 2,344 Bytes
983d072
b9e7f35
 
 
 
 
983d072
08a7509
 
7134d92
08a7509
 
 
 
8d68db5
7134d92
08a7509
 
44aa685
 
 
b9e7f35
44aa685
b9e7f35
44aa685
 
 
 
d633848
44aa685
d633848
44aa685
 
 
 
 
544b4ee
44aa685
 
544b4ee
44aa685
 
544b4ee
44aa685
 
 
544b4ee
44aa685
 
 
 
544b4ee
9ce81f8
 
44aa685
08a7509
44aa685
 
b9e7f35
44aa685
b9e7f35
44aa685
 
 
 
 
 
b9e7f35
44aa685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import requests
import io
import random
import os
from PIL import Image

list_models = [
    "SDXL-1.0",
    "SD-1.5",
    "OpenJourney-V4",
    "Anything-V4",
    "Disney-Pixar-Cartoon",
    "Pixel-Art-XL",
    "Dalle-3-XL",
    "Midjourney-V4-XL",
]

# Your generate_txt2img function
def generate_txt2img(current_model, prompt, is_negative, image_style, steps, cfg_scale, seed):
    # ... (Your function implementation)

# Enhanced CSS for better styling
css = """
body {
    font-family: 'Helvetica Neue', sans-serif;
    background-color: #f7f8fa;
}
.gradio-container {
    max-width: 800px;
    margin: auto;
    padding-top: 1rem;
    padding-bottom: 1rem;
    border-radius: 10px;
    background-color: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}
.gradio-row {
    margin-bottom: 1rem;
}
.gradio-button, .gradio-dropdown, .gradio-textbox {
    border-radius: 5px;
}
.gradio-button {
    background-color: #4CAF50; /* Green */
    color: white;
}
.gradio-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
"""

# Gradio interface setup
with gr.Blocks(css=css) as demo:
    gr.Markdown("# AI Image Generation")

    with gr.Row():
        current_model = gr.Dropdown(label="Select Model", choices=list_models, value=list_models[0])

    with gr.Row():
        text_prompt = gr.Textbox(label="Enter Prompt", placeholder="Describe the image you want to generate", lines=2)
        text_button = gr.Button("Generate Image")

    with gr.Row():
        image_output = gr.Image(type="pil", label="Generated Image")

    with gr.Accordion("Advanced settings"):
        with gr.Column():
            negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter elements to avoid in the image", lines=2)
            image_style = gr.Dropdown(label="Select Style", choices=["None", "Cinematic", "Digital Art", "Portrait"], value="None")
            steps = gr.Slider(minimum=1, maximum=100, value=50, label="Steps")
            cfg_scale = gr.Slider(minimum=1, maximum=20, value=7, label="CFG Scale")
            seed = gr.Number(label="Seed", value=random.randint(0, 2**32 - 1))

    text_button.click(
        func=generate_txt2img,
        inputs=[current_model, text_prompt, negative_prompt, image_style, steps, cfg_scale, seed],
        outputs=image_output
    )

demo.launch()