File size: 3,212 Bytes
ef03112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
102
import gradio as gr
import random

# ----- 1) กำหนดหมวดต่าง ๆ -----
characters = [
    "shy kitten", "brave puppy", "tiny fairy", "silly robot", "kind princess",
    "friendly dragon", "playful elf", "curious mermaid", "gentle unicorn", "happy ninja"
]
places = [
    "in a fluffy cloud kingdom", "on a giant rainbow slide", "inside a magical treehouse",
    "near a crystal waterfall", "in a cotton-candy land", "on a floating island",
    "beside a sparkling river", "at a mushroom village", "inside a glowing cave", "on a giant lily pad"
]
activities = [
    "singing a funny song", "dancing with butterflies", "riding a magical bike",
    "painting colorful stars", "telling hilarious jokes", "juggling shining orbs",
    "building candy houses", "playing hide-and-seek", "collecting glowing gems", "spinning in circles"
]
styles = [
    "cartoon style", "pastel style", "watercolor style", "3D clay style", "pixel art style",
    "comic style", "chibi style", "neon style", "storybook style", "fantasy style"
]
weirds = [
    "with giant lollipops", "surrounded by friendly ghosts", "while time is frozen",
    "under a raining confetti sky", "next to floating musical notes",
    "with oversized flowers", "where everything is upside down", 
    "in a world without gravity", "amidst talking clouds", "inside a giant soap bubble"
]

# ----- 2) ฟังก์ชันสร้าง Prompt -----
def spin_the_wheel():
    c = random.choice(characters)
    p = random.choice(places)
    a = random.choice(activities)
    s = random.choice(styles)
    w = random.choice(weirds)

    # โครงสร้างประโยค
    # "Behold a [character], [activity] [place] in [style] [weird]!"
    prompt = f"Behold a {c}, {a} {p} in {s} {w}!"
    return prompt

# ----- 3) สร้าง UI Gradio -----
custom_css = """
body {
    background-color: #FFFEE0;
    font-family: "Comic Sans MS", "Comic Sans", cursive;
}

#title {
    text-align: center;
    color: #FF6F91;
    margin-top: 20px;
    font-size: 2.2rem;
    font-weight: bold;
}

#subtitle {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

#prompt-box {
    font-size: 20px;
    min-height: 60px;
    padding: 10px;
    text-align: center;
    border: 2px solid #FFB74D;
    border-radius: 12px;
    background-color: #FFF3E0;
}
"""

with gr.Blocks(css=custom_css) as demo:
    gr.Markdown("<h1 id='title'>ZenityX Dream Explorers</h1>")
    gr.Markdown("""
    <p id='subtitle'>
    สวัสดีจ้า หนูน้อย! พร้อมหรือยังที่จะหมุนวงล้อ<br>
    เพื่อสร้าง Prompt สุดแฟนตาซีสำหรับ AI เจนภาพ?
    </p>
    """)
    
    # ปุ่ม Spin
    spin_btn = gr.Button("Spin the Wheel!")
    
    # กล่องแสดง Prompt
    prompt_output = gr.Textbox(
        label="Dream Prompt",
        interactive=False,
        elem_id="prompt-box"
    )
    
    # Event: เมื่อกดปุ่ม -> สร้าง Prompt
    spin_btn.click(
        fn=spin_the_wheel,
        inputs=[],
        outputs=prompt_output
    )

demo.launch()