File size: 14,832 Bytes
061d802
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650c805
 
061d802
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
import os
#Set the environment variables
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"
IS_SHARED_SPACE = "Surn/HexaGridCreator" in os.environ.get('SPACE_ID', '')

# Set the temporary folder location
os.environ['TEMP'] = r'e:\\TMP'
os.environ['TMPDIR'] = r'e:\\TMP'
os.environ['XDG_CACHE_HOME'] = r'E:\\cache'
os.environ['USE_FLASH_ATTENTION'] = '1'
os.environ['XFORMERS_FORCE_DISABLE_TRITON']= '1'

# constants.py contains all the constants used in the project
os.environ["HF_TOKEN"] = ""
HF_API_TOKEN = os.getenv("HF_TOKEN")
default_lut_example_img = "./LUT/daisy.jpg"
os.environ["HF_TOKEN"] = """
HF_API_TOKEN = os.getenv("HF_TOKEN")

PROMPTS = {
    "Map1": "eight_color (tabletop_map built from small hexagon pieces) as ((empty black on all sides), barren alien_world_map), with light_blue_is_rivers and brown_is_mountains and red_is_volcano and [white_is_snow at the top and bottom of map] as (four_color background: light_blue, green, tan, brown), horizontal_gradient is (brown to tan to green to light_blue to blue) and vertical_gradient is (white to blue to (green, tan and red) to blue to white), (middle is dark, no_reflections, no_shadows), ((partial hexes on edges and sides are black))",
    "Map2": "eight_color (tabletop_map built from small hexagon pieces) as alien_world_map, with light_blue_is_rivers and brown_is_mountains and red_is_volcano and [white_is_snow at the top and bottom of map] as (four_color background: light_blue, green, tan, brown), horizontal_gradient is (brown to tan to green to light_blue to blue) and vertical_gradient is (white to blue to (green, tan and red) to blue to white), (middle is dark, no_reflections, no_shadows), ((partial hexes on edges and sides are black)), overhead_view, from_above",
    "Map3": "top-down, bird's-eye view of A mystic forest-themed map viewed from directly above, showcasing detailed terrain features such as lakes, dense forests, magical flora, and hexagonal grids. The map is designed for tabletop gaming, emphasizing clarity and strategic elements, eight_color (tabletop_map built from small hexagon pieces) as alien_forest_world_map, with light_blue_is_lakes and green_is_forests and purple_is_alien_flora and [white_is_snow at the top and bottom of map] as (four_color background: light_blue, green, purple, brown), horizontal_gradient is (green to purple to light_blue to blue) and vertical_gradient is (white to blue to (green, purple and brown) to blue to white), (middle is dark, no_reflections, no_shadows), ((partial hexes on edges and sides are black))",
    "Map4": "A top-down, bird's-eye view of a medieval battlefield map for tabletop games, eight_color (tabletop_map built from small hexagon pieces) as mystic_forest_world_map, with teal_is_lakes and dark_green_is_forest and violet_is_magic_fauna and [white_is_snow at the top and bottom of map] as (four_color background: teal, dark_green, violet, brown), horizontal_gradient is (brown to violet to teal to blue) and vertical_gradient is (white to blue to (dark_green, violet and brown) to blue to white), (middle is enchanted, no_reflections, no_shadows), ((partial hexes on edges and sides are black)), viewed from above, flat and illustrative, not a map of the Earth",
    "Alien Landscape": "top-down view of a barren alien world map made from hexagon pieces. Features light blue rivers, brown mountains, red volcanoes, and white snow at the top and bottom. Background colors: light blue, green, tan, brown. Partial hexes on edges are black.",
    "Alien World": "top-down view of an alien world map built from hexagon pieces. Includes rivers, mountains, volcanoes, and snowy areas. Uses a four-color background: light blue, green, tan, brown. Partial edge hexes are black. Overhead view.",
    "Mystic Forest": "top-down view of a mystic forest map with lakes, dense forests, magical flora, and hexagonal grids. Designed for clarity in tabletop gaming. Background colors: light blue, green, purple, brown. Partial hexes on edges are black.",
    "Medieval Battlefield": "top-down view of a medieval battlefield map featuring lakes, forests, and magic fauna. Emphasizes clarity and strategy for tabletop games. Background colors: teal, dark green, violet, brown. Partial edge hexes are black. Viewed from above.",
    "Prompt": None  # Indicates that the prompt should be taken from prompt_textbox
}

NEGATIVE_PROMPTS = {
    "Map1": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Map2": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Map3": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Map4": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Alien Landscape": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Alien World": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Mystic Forest": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Medieval Battlefield": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric",
    "Prompt": None  # Indicates that the negative prompt should be taken from negative_prompt_textbox
}

# Directory containing the pre-rendered hexagon maps
ASSETS_DIR = "images/prerendered"

# List of pre-rendered hexagon map files
PRE_RENDERED_MAPS = [
    "alien_orb_land_1.png",
    "alien_prarie_1.png",
    "alien_world_1.jpg",
    "alien_world_2.jpg",
    "alien_world_3.jpg",
    "alien_world_4.jpg",
    "alien_world_5.jpg",
    "canyon_water_1.png",
    "dark_dirt_elevations_1.png",
    "elevated_peninsula_1.png",
    "Firefly_alien_canyons_1.png",
    "Firefly_alien_canyons_2.jpg",
    "Firefly_alien_canyons_2.png",
    "Firefly_alien_dry_canyons_1.jpg",
    "Firefly_alien_dry_canyons_2.jpg",
    "Firefly_alien_map_1.jpg",
    "Firefly_hpg_terrain_1.png",
    "Firefly_hpg_terrain_2.png",
    "Firefly_river_dry_1.jpg",
    "Firefly_river_running_1.jpg",
    "Firefly_topographical_alien_desert_1.jpg",
    "Firefly_topographical_canyon_1.jpg",
    "Firefly_topographical_height_map_1.jpg",
    "Firefly_topographical_height_map_2.jpg",
    "Firefly_topographical_height_map_3.jpg",
    "Firefly_topographical_height_map_5.jpg",
    "Firefly_topographical_height_map_6.jpg",
    "Firefly_topographical_marble_1.jpg",
    "Firefly_topographical_moon_1.jpg",
    "green_farming alien_world_1.jpg",
    "green_farming alien_world_2.jpg",
    "grey_barren_alien_world_1.jpg",
    "grey_barren_alien_world_2.jpg",
    "grey_barren_alien_world_3.jpg",
    "grey_barren_alien_world_4.jpg",
    "grey_barren_alien_world_5.jpg",
    "grey_barren_alien_world_6.jpg",
    "grey_barren_alien_world_7.jpg",
    "grey_waterless_alien_world_map.jpg",
    "grid_1.jpg",
    "Hex_gen_map.PNG",
    "hex_grass_dirty.png",
    "hex_military_industrial alien_world_map.jpg",
    "hex_mixed_elevations_battlefield_1.png",
    "hex_mixed_elevations_battlefield_2.png",
    "mixed_elevations_battlefield_3.png",
    "n6W9Hc.png",
    "oasis_mixed_elevations_1.png",
    "pic526383.png",
    "red_volcanic_alien_1.jpg",
    "red_volcanic_alien_2.jpg",
    "red_volcanic_alien_3.jpg",
    "red_volcanic_alien_4.jpg",
    "roadway_1.png",
    "snowy_rolling_hills_1.png",
    "volcanic alien_world_map.jpg",
    "war-torn_post-apocalyptic_alien_world_map.jpg"
]


# Generate a dictionary with cleaned-up names as keys and file paths as values
PRE_RENDERED_MAPS_JSON = {
    os.path.splitext(file.replace("_", " ").replace("-", " ").replace("  ", " ").strip())[0]: os.path.join(ASSETS_DIR, file)
    for file in PRE_RENDERED_MAPS
}

PRE_RENDERED_MAPS_JSON = "{'alien world 1': 'images/prerendered/alien_world_1.jpg', 'alien world 2': 'images/prerendered/alien_world_2.jpg', 'alien world 3': 'images/prerendered/alien_world_3.jpg', 'alien world 4': 'images/prerendered/alien_world_4.jpg', 'alien world 5': 'images/prerendered/alien_world_5.jpg', 'green farming alien world 1': 'images/prerendered/green_farming alien_world_1.jpg', 'green farming alien world 2': 'images/prerendered/green_farming alien_world_2.jpg', 'grey barren alien world 1': 'images/prerendered/grey_barren_alien_world_1.jpg', 'grey barren alien world 2': 'images/prerendered/grey_barren_alien_world_2.jpg', 'grey barren alien world 3': 'images/prerendered/grey_barren_alien_world_3.jpg', 'grey barren alien world 4': 'images/prerendered/grey_barren_alien_world_4.jpg', 'grey barren alien world 5': 'images/prerendered/grey_barren_alien_world_5.jpg', 'grey barren alien world 6': 'images/prerendered/grey_barren_alien_world_6.jpg', 'grey barren alien world 7': 'images/prerendered/grey_barren_alien_world_7.jpg', 'grey waterless alien world map': 'images/prerendered/grey_waterless_alien_world_map.jpg', 'Hex gen map': 'images/prerendered/Hex_gen_map.PNG', 'military industrial alien world map': 'images/prerendered/military_industrial alien_world_map.jpg', 'red volcanic alien 1': 'images/prerendered/red_volcanic_alien_1.jpg', 'red volcanic alien 2': 'images/prerendered/red_volcanic_alien_2.jpg', 'red volcanic alien 3': 'images/prerendered/red_volcanic_alien_3.jpg', 'red volcanic alien 4': 'images/prerendered/red_volcanic_alien_4.jpg', 'volcanic alien world map': 'images/prerendered/volcanic alien_world_map.jpg', 'war torn post apocalyptic alien world map': 'images/prerendered/war-torn_post-apocalyptic_alien_world_map.jpg'}"
# Available FLUX model names
MODELS = [
    "black-forest-labs/FLUX.1-schnell",
    "black-forest-labs/FLUX.1-dev",
    "ostris/Flex.1-alpha"
]
# Available LoRA weights
LORA_WEIGHTS = [
    "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design",
    "Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1",
    "Cossale/Frames2-Flex.1",
    "XLabs-AI/flux-lora-collection/anime_lora.safetensors",
    "XLabs-AI/flux-lora-collection/scenery_lora.safetensors",
    "XLabs-AI/flux-lora-collection/disney_lora.safetensors"
]

# Map each LoRA weight to its corresponding model
LORA_TO_MODEL = {
    "Yuanshi/OminiControl": "black-forest-labs/FLUX.1-schnell",
    "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design": "black-forest-labs/FLUX.1-dev",
    "Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1": "black-forest-labs/FLUX.1-dev",
    "Cossale/Frames2-Flex.1": "ostris/Flex.1-alpha",
    "AlekseyCalvin/HSTcolorFlexAlpha": "ostris/Flex.1-alpha",
    "XLabs-AI/flux-lora-collection/anime_lora.safetensors":"black-forest-labs/FLUX.1-dev",
    "XLabs-AI/flux-lora-collection/scenery_lora.safetensors":"black-forest-labs/FLUX.1-dev",
    "XLabs-AI/flux-lora-collection/disney_lora.safetensors":"black-forest-labs/FLUX.1-dev"
}

# Detailed LoRA weight configurations
LORA_DETAILS = {
    "AlekseyCalvin/HSTcolorFlexAlpha" : [
        {
            "trigger_words": "(6kStepsCkpt) HST style autochrome photograph",
        },
        {
            "weight_name": "HSToricColorFlex_6000steps_LoRAforFluxOrFlex_32dim64alpha.safetensors",
        },
        {
            "notes": "You should use (6kStepsCkpt) HST style autochrome photograph as trigger words."
        },
        {
            "parameters" :{
                "num_inference_steps": "30"
            }
        }
        ],
    "XLabs-AI/flux-lora-collection/anime_lora.safetensors":[
        {
            "lora_collection": "XLabs-AI/flux-lora-collection",
            "weight_name": "anime_lora.safetensors"
        },
        {
            "trigger_words": "anime,",
        },
        {
            "notes": "You should use ',anime' as trigger words at the end. @6min"
        },
        {
            "parameters" :{
                "num_inference_steps": "30"
            }
        }
        ],
    "XLabs-AI/flux-lora-collection/scenery_lora.safetensors":[
        {
            "lora_collection": "XLabs-AI/flux-lora-collection",
            "weight_name": "scenery_lora.safetensors"
        },
        {
            "trigger_words": "scenery style,",
        },
        {
            "notes": "You should use ',scenery style' as trigger words at the end. @6min"
        },
        {
            "parameters" :{
                "num_inference_steps": "30"
            }
        }
        ],
    "XLabs-AI/flux-lora-collection/disney_lora.safetensors":[
        {
            "lora_collection": "XLabs-AI/flux-lora-collection",
            "weight_name": "disney_lora.safetensors"
        },
        {
            "trigger_words": "disney style,",
        },
        {
            "notes": "You should use ',disney style' as trigger words at the end. @6min "
        },
        {
            "parameters" :{
                "num_inference_steps": "30"
            }
        }
        ],
    "Cossale/Frames2-Flex.1": [
        {
            "weight_name": "backdrops_v2.safetensors",
            "adapter_name": "backdrops_v2"
        },
        {
            "trigger_words": "FRM$",
        },
        {
            "notes": "You should use FRM$ as trigger words. @1.5 minutes"
        },
        {
            "parameters" :{
                "num_inference_steps": "50"
            }
        }
    ],
    "Yuanshi/OminiControl": [
        {
            "weight_name": "omini/subject_512.safetensors",
            "adapter_name": "subject_512"
        },
        {
            "weight_name": "omini/subject_1024_beta.safetensors",
            "adapter_name": "subject_1024"
        },
        {
            "parameters" :{
                "num_inference_steps": "8",
                "guidance_scale": "0"
            }
        },
        {
            "notes": "Select an Image as a guide."
        }
    ],
    "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design": [
        {
            "notes": "You should use wablogo, logo, Minimalist as trigger words.. @4.8min"
        },
        {
            "trigger_words": "wablogo, logo, Minimalist ",
        },
        {
            "pipe" :{
                "fuse_lora": {"lora_scale":0.8}
            }
        },
        {
            "parameters" :{
                "num_inference_steps": "38"
            }
        }
    ],
    "Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1": [
        {
            "notes": "Use fractalLand at the start of the prompts to activate the fractal elements. . @4.8min"
        },
        {
            "trigger_words": "fractalLand ",
        },
        {
            "parameters" :{
                "max_sequence_length": "512",
                "guidance_scale": "3.5",
                "num_inference_steps": "38"
            }
        }
    ]
}

temp_files = []