File size: 2,683 Bytes
b197a8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# components/locations.py
:contentReference[oaicite:2]{index=2}
:contentReference[oaicite:3]{index=3}
:contentReference[oaicite:4]{index=4}
import json
import os

:contentReference[oaicite:5]{index=5}
    :contentReference[oaicite:6]{index=6}
    :contentReference[oaicite:7]{index=7}
    :contentReference[oaicite:8]{index=8}
    :contentReference[oaicite:9]{index=9}
    :contentReference[oaicite:10]{index=10}
        :contentReference[oaicite:11]{index=11}

def location_tab():
    :contentReference[oaicite:12]{index=12}
        :contentReference[oaicite:13]{index=13}
            :contentReference[oaicite:14]{index=14}
                :contentReference[oaicite:15]{index=15}
                :contentReference[oaicite:16]{index=16}
                    :contentReference[oaicite:17]{index=17}
                    :contentReference[oaicite:18]{index=18}
                    value="Forest"
                )
                :contentReference[oaicite:19]{index=19}
                    label="Size",
                    :contentReference[oaicite:20]{index=20}
                    value="Medium"
                )
                :contentReference[oaicite:21]{index=21}
                    :contentReference[oaicite:22]{index=22}
                    :contentReference[oaicite:23]{index=23}
                    value="Moderate"
                )
                :contentReference[oaicite:24]{index=24}
                    label="Theme",
                    :contentReference[oaicite:25]{index=25}
                    value="Mystical"
                )
                :contentReference[oaicite:26]{index=26}
                :contentReference[oaicite:27]{index=27}

                export_btn = gr.Button("๐Ÿ’พ Save Location to Gallery")
                export_status = gr.Textbox(label="Export Status")

        def build_and_generate(name, loc_type, size, danger, theme):
            data = {
                "name": name,
                "location_type": loc_type,
                "size": size,
                "danger_level": danger,
                "theme": theme
            }
            return generate_location_image(data, art_style="Concept Art")

        gen_btn.click(
            build_and_generate,
            inputs=[name, loc_type, size, danger, theme],
            outputs=image_out
        )

        export_btn.click(
            lambda n, lt, sz, dg, th, img: save_to_gallery(
                "location",
                {"name": n, "type": lt, "size": sz, "danger_level": dg, "theme": th},
                img
            ) or "โœ… Location saved!",
            inputs=[name, loc_type, size, danger, theme, image_out],
            outputs=export_status
        )