HexaGrid / utils /constants.py
Surn's picture
Add Blur and Grid Transformation
8001a73
# utils/constants.py
# constants.py contains all the constants used in the project such as the default LUT example image, prompts, negative prompts, pre-rendered maps, models, LoRA weights, and more.
# execptions made for some environmental variables
import os
from pathlib import Path
from dotenv import load_dotenv
import numpy as np
#Set the environment variables
#os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:256,expandable_segments:True"
#os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
#os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
#os.environ['CUDA_MODULE_LOADING']='LAZY'
#os.environ['USE_FLASH_ATTENTION'] = '1'
#os.environ['XFORMERS_FORCE_DISABLE_TRITON']= '1'
#os.environ['XFORMERS_FORCE_DISABLE_TORCHSCRIPT']= '1'
#os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
#os.environ["PYTORCH_NVML_BASED_CUDA_CHECK"] = "1"
#os.environ["CUDA_VISIBLE_DEVICES"] = "0"
#os.environ["NVIDIA_VISIBLE_DEVICES"] = "0"
#os.environ["ZEROGPU_VERSION"] = "2"
#os.environ["ZEROGPU_V2"] = "true"
#os.environ["ZERO_GPU_V2"] = "true"
#os.environ["ZERO_GPU_PATCH_TORCH_DEVICE"]='1'
IS_SHARED_SPACE = "Surn/HexaGrid" in os.environ.get('SPACE_ID', '')
# Load environment variables from .env file
dotenv_path = Path(__file__).parent.parent / '.env'
load_dotenv(dotenv_path)
# Function to load env vars from .env and create Python variables
def load_env_vars(env_path):
try:
with open(env_path, 'r') as file:
for line in file:
# Skip empty lines or comments
line = line.strip()
if line and not line.startswith('#'):
# Split on the first '=' only
if '=' in line:
key, value = line.split('=', 1)
key = key.strip()
value = value.strip()
# Dynamically create a Python variable with the key name
globals()[key] = value
# Also update os.environ (optional, for consistency)
os.environ[key] = value
except FileNotFoundError:
print(f"Warning: .env file not found at {env_path}")
# 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'
USE_FLASH_ATTENTION = os.getenv("USE_FLASH_ATTENTION", "0") == "1"
HF_API_TOKEN = os.getenv("HF_TOKEN")
if not HF_API_TOKEN:
raise ValueError("HF_TOKEN is not set. Please check your .env file.")
default_lut_example_img = "./LUT/daisy.jpg"
MAX_SEED = np.iinfo(np.int32).max
TARGET_SIZE = (2688,1536)
BASE_HEIGHT = 640
SCALE_FACTOR = (12/5)
TMPDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
os.makedirs(TMPDIR, exist_ok=True)
PROMPTS = {
"Mecha Wasteland Arena": "Regional overhead view, directly from above, centered on the map, orthographic Mecha battlefield map. post-industrial wasteland with crumbling structures, volcanic ridges, scrapyards, and ash plains. Features elevated overwatch positions for long-range combat and tight brawling areas for close-quarters engagements. Partial edge hexes are black. Colors: red, gray, muted orange, ash white, dark brown.",
"BorderBlack": "Planetary overhead view, directly from above, centered on the planet’s surface, orthographic hexagon-based alien world map with black borders. Features rivers, mountains, volcanoes, and polar snow regions. Colors: light blue, green, tan, brown. No reflections or shadows. Partial edge hexes are black.",
"Earth": "Planetary overhead view, directly from above, centered on the planet’s surface, orthographic Earth-like world map with rivers, mountains, volcanoes, and polar snow regions. Colors: light blue, green, tan, brown. No reflections or shadows. Partial edge hexes are black.",
"Beeuty": "Regional overhead view, directly from above, centered on the map, orthographic tabletop gaming map with honeycomb-shaped terrain, lakes, dense forests, magical flora, and hex grids. Designed for clarity and strategic gameplay. Colors: yellow, green, purple, brown. Partial edge hexes are black.",
"Scifi City": "Regional overhead view, directly from above, centered on the map, orthographic futuristic urban battlefield map with lakes, forests, ruined buildings, and city streets. Designed for clarity and strategic gameplay in tabletop games. Colors: teal, dark green, violet, brown. Partial edge hexes are black.",
"Alien Landscape": "Planetary overhead view, directly from above, centered on the planet’s surface, orthographic barren alien world map composed of hexagon tiles. Features light blue rivers, brown mountains, red volcanoes, and white polar snow. Colors: light blue, green, tan, brown. Partial edge hexes are black.",
"Alien World": "Planetary overhead view, directly from above, centered on the planet’s surface, orthographic alien world map built from hexagon tiles. Includes rivers, mountains, volcanoes, and snowy regions. Colors: light blue, green, tan, brown. Partial edge hexes are black.",
"Mystic Forest": "Regional overhead view, directly from above, centered on the map, orthographic mystic forest map with lakes, dense forests, magical flora, and hex grids. Designed for clarity and strategic gameplay in tabletop gaming. Colors: light blue, green, purple, brown. Partial edge hexes are black.",
"Medieval Battlefield": "Regional overhead view, directly from above, centered on the map, orthographic medieval battlefield map with lakes, forests, and magical fauna. Designed for clarity and strategic gameplay in tabletop games. Colors: teal, dark green, violet, brown. Partial edge hexes are black.",
"Dungeon Interior": "Regional overhead view, directly from above, centered on the map, orthographic dungeon interior map for tabletop gaming. Features stone walls, corridors, rooms with doors, traps, and treasure chests. Designed for clarity and strategic gameplay. Colors: gray, brown, dark blue. Partial edge hexes are black.",
"Desert Wasteland": "Regional overhead view, directly from above, centered on the map, orthographic desert wasteland map for tabletop gaming. Features sand dunes, rocky canyons, oases, and ancient ruins. Colors: yellow, tan, brown, blue, green. Partial edge hexes are black.",
"Prompt": None # Indicates that the prompt should be taken from prompt_textbox
}
NEGATIVE_PROMPTS = {
"Mecha Wasteland Arena": "humans, old_buildings, water, bright colors, text, logos, shadows, Earth geography, isometric, camera_angle",
"BorderBlack": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric, camera_angle",
"Earth": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, missing map of the Earth, isometric, camera_angle",
"Beeuty": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, map of the Earth, isometric, camera_angle",
"Scifi City": "humans, missing_buildings, vehicles, text, logos, reflections, shadows, Earth, isometric, camera_angle",
"Alien Landscape": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric, camera_angle",
"Alien World": "Earth, humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric, camera_angle",
"Mystic Forest": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric, camera_angle",
"Medieval Battlefield": "humans, modern_buildings, vehicles, text, logos, reflections, shadows, realistic map of the Earth, isometric, camera_angle",
"Dungeon Interior":"humans, modern_buildings, vehicles, text, logos, reflections, shadows, outdoor elements, realistic map of the Earth, isometric, camera_angle",
"Desert Wasteland":"humans, modern_buildings, vehicles, text, logos, reflections, shadows, lush forests, large bodies of water, snow, realistic map of the Earth, isometric, camera_angle",
"Prompt": None # Indicates that the negative prompt should be taken from negative_prompt_textbox
}
# Directory containing the pre-rendered hexagon maps
PRERENDER_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.png', 'alien_world_2.png', 'alien_world_3.png', 'alien_world_4.png', 'alien_world_5.png', 'BurntCity.png', 'canyon_water_1.png', 'CONQ_Caustic_Valley.png', 'CONQ_Frozen_City.png', 'CONQ_Hellebore_Springs.png', 'CONQ_Terra_Therma.png', 'CONQ_Viridian_Bog.png', 'cute3dkawaii.PNG', 'dark_dirt_elevations_1.png', 'donald_park.png', 'elevated_peninsula_1.png', 'Firefly_alien_canyons_1.png', 'Firefly_alien_canyons_2.png', 'Firefly_alien_dry_canyons_1.png', 'Firefly_alien_dry_canyons_2.png', 'Firefly_alien_map_1.png', 'Firefly_hpg_terrain_1.png', 'Firefly_hpg_terrain_2.png', 'Firefly_river_dry_1.png', 'Firefly_river_running_1.png', 'Firefly_topographical_alien_desert_1.png', 'Firefly_topographical_canyon_1.png', 'Firefly_topographical_height_map_1.png', 'Firefly_topographical_height_map_2.png', 'Firefly_topographical_height_map_3.png', 'Firefly_topographical_height_map_5.png', 'Firefly_topographical_height_map_6.png', 'Firefly_topographical_marble_1.png', 'Firefly_topographical_moon_1.png', 'fractal_islands.png', 'Genison.png', 'green_farming_alien_world_1.png', 'green_farming_alien_world_2.png', 'grey_barren_alien_world_1.png', 'grey_barren_alien_world_2.png', 'grey_barren_alien_world_3.png', 'grey_barren_alien_world_4.png', 'grey_barren_alien_world_5.png', 'grey_barren_alien_world_6.png', 'grey_barren_alien_world_7.png', 'grey_waterless_alien_world_map.png', 'grid_1.png', 'Hex_gen_map.png', 'hex_grass_dirty.png', 'hex_military_industrial_alien_world_map.png', 'hex_mixed_elevations_battlefield_1.png', 'hex_mixed_elevations_battlefield_2.png', 'hex_tree_territory.png', 'lake_city.png', 'mickey_lagoon.png', 'mixed_elevations_battlefield_3.png', 'n6W9Hc.png', 'oasis_mixed_elevations_1.png', 'pic526383.png', 'pinecone_islands.png', 'purple_pines.png', 'red_volcanic_alien_1.png', 'red_volcanic_alien_2.png', 'red_volcanic_alien_3.png', 'red_volcanic_alien_4.png', 'roadway_1.png', 'snowy_lake.png', 'snowy_rolling_hills_1.png', 'volcanic_alien_world_map.png', 'war_torn_post_apocalyptic_alien_world_map.png']
# # Create full paths for pre-rendered maps
# pre_rendered_maps_paths = [os.path.join(PRERENDER_DIR, map_file).replace("\\", "/") for map_file in PRE_RENDERED_MAPS]
# pre_rendered_maps_paths_api_file = [f"./gradio_api/file={map_path}" for map_path in pre_rendered_maps_paths]
# 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(PRERENDER_DIR, file)
# for file in PRE_RENDERED_MAPS
#}
#PRE_RENDERED_MAPS_JSON
#{'alien orb land 1': 'images/prerendered/alien_orb_land_1.png', 'alien prarie 1': 'images/prerendered/alien_prarie_1.png', 'alien world 1': 'images/prerendered/alien_world_1.png', 'alien world 2': 'images/prerendered/alien_world_2.png', 'alien world 3': 'images/prerendered/alien_world_3.png', 'alien world 4': 'images/prerendered/alien_world_4.png', 'alien world 5': 'images/prerendered/alien_world_5.png', 'BurntCity': 'images/prerendered/BurntCity.png', 'canyon water 1': 'images/prerendered/canyon_water_1.png', 'CONQ Caustic Valley': 'images/prerendered/CONQ_Caustic_Valley.png', 'CONQ Frozen City': 'images/prerendered/CONQ_Frozen_City.png', 'CONQ Hellebore Springs': 'images/prerendered/CONQ_Hellebore_Springs.png', 'CONQ Terra Therma': 'images/prerendered/CONQ_Terra_Therma.png', 'CONQ Viridian Bog': 'images/prerendered/CONQ_Viridian_Bog.png', 'cute3dkawaii': 'images/prerendered/cute3dkawaii.png', 'dark dirt elevations 1': 'images/prerendered/dark_dirt_elevations_1.png', 'donald park': 'images/prerendered/donald_park.png', 'elevated peninsula 1': 'images/prerendered/elevated_peninsula_1.png', 'Firefly alien canyons 1': 'images/prerendered/Firefly_alien_canyons_1.png', 'Firefly alien canyons 2': 'images/prerendered/Firefly_alien_canyons_2.png', 'Firefly alien dry canyons 1': 'images/prerendered/Firefly_alien_dry_canyons_1.png', 'Firefly alien dry canyons 2': 'images/prerendered/Firefly_alien_dry_canyons_2.png', 'Firefly alien map 1': 'images/prerendered/Firefly_alien_map_1.png', 'Firefly hpg terrain 1': 'images/prerendered/Firefly_hpg_terrain_1.png', 'Firefly hpg terrain 2': 'images/prerendered/Firefly_hpg_terrain_2.png', 'Firefly river dry 1': 'images/prerendered/Firefly_river_dry_1.png', 'Firefly river running 1': 'images/prerendered/Firefly_river_running_1.png', 'Firefly topographical alien desert 1': 'images/prerendered/Firefly_topographical_alien_desert_1.png', 'Firefly topographical canyon 1': 'images/prerendered/Firefly_topographical_canyon_1.png', 'Firefly topographical height map 1': 'images/prerendered/Firefly_topographical_height_map_1.png', 'Firefly topographical height map 2': 'images/prerendered/Firefly_topographical_height_map_2.png', 'Firefly topographical height map 3': 'images/prerendered/Firefly_topographical_height_map_3.png', 'Firefly topographical height map 5': 'images/prerendered/Firefly_topographical_height_map_5.png', 'Firefly topographical height map 6': 'images/prerendered/Firefly_topographical_height_map_6.png', 'Firefly topographical marble 1': 'images/prerendered/Firefly_topographical_marble_1.png', 'Firefly topographical moon 1': 'images/prerendered/Firefly_topographical_moon_1.png', 'fractal islands': 'images/prerendered/fractal_islands.png', 'Genison': 'images/prerendered/Genison.png', 'green farming alien world 1': 'images/prerendered/green_farming_alien_world_1.png', 'green farming alien world 2': 'images/prerendered/green_farming_alien_world_2.png', 'grey barren alien world 1': 'images/prerendered/grey_barren_alien_world_1.png', 'grey barren alien world 2': 'images/prerendered/grey_barren_alien_world_2.png', 'grey barren alien world 3': 'images/prerendered/grey_barren_alien_world_3.png', 'grey barren alien world 4': 'images/prerendered/grey_barren_alien_world_4.png', 'grey barren alien world 5': 'images/prerendered/grey_barren_alien_world_5.png', 'grey barren alien world 6': 'images/prerendered/grey_barren_alien_world_6.png', 'grey barren alien world 7': 'images/prerendered/grey_barren_alien_world_7.png', 'grey waterless alien world map': 'images/prerendered/grey_waterless_alien_world_map.png', 'grid 1': 'images/prerendered/grid_1.png', 'Hex gen map': 'images/prerendered/Hex_gen_map.png', 'hex grass dirty': 'images/prerendered/hex_grass_dirty.png', 'hex military industrial alien world map': 'images/prerendered/hex_military_industrial_alien_world_map.png', 'hex mixed elevations battlefield 1': 'images/prerendered/hex_mixed_elevations_battlefield_1.png', 'hex mixed elevations battlefield 2': 'images/prerendered/hex_mixed_elevations_battlefield_2.png', 'hex tree territory': 'images/prerendered/hex_tree_territory.png', 'lake city': 'images/prerendered/lake_city.png', 'mickey lagoon': 'images/prerendered/mickey_lagoon.png', 'mixed elevations battlefield 3': 'images/prerendered/mixed_elevations_battlefield_3.png', 'n6W9Hc': 'images/prerendered/n6W9Hc.png', 'oasis mixed elevations 1': 'images/prerendered/oasis_mixed_elevations_1.png', 'pic526383': 'images/prerendered/pic526383.png', 'pinecone islands': 'images/prerendered/pinecone_islands.png', 'purple pines': 'images/prerendered/purple_pines.png', 'red volcanic alien 1': 'images/prerendered/red_volcanic_alien_1.png', 'red volcanic alien 2': 'images/prerendered/red_volcanic_alien_2.png', 'red volcanic alien 3': 'images/prerendered/red_volcanic_alien_3.png', 'red volcanic alien 4': 'images/prerendered/red_volcanic_alien_4.png', 'roadway 1': 'images/prerendered/roadway_1.png', 'snowy lake': 'images/prerendered/snowy_lake.png', 'snowy rolling hills 1': 'images/prerendered/snowy_rolling_hills_1.png', 'volcanic alien world map': 'images/prerendered/volcanic_alien_world_map.png', 'war torn post apocalyptic alien world map': 'images/prerendered/war_torn_post_apocalyptic_alien_world_map.png'}
##PRE_RENDERED_MAPS_JSON = { key: { 'file': value, 'quality': 0 } for key, value in PRE_RENDERED_MAPS_JSON.items()}
PRE_RENDERED_MAPS_JSON_LEVELS = {
'alien orb land 1': {'file': 'images/prerendered/alien_orb_land_1.png', 'thumbnail': 'images/prerendered/th/alien_orb_land_1.png', 'quality': 0},
'alien prarie 1': {'file': 'images/prerendered/alien_prarie_1.png', 'thumbnail': 'images/prerendered/th/alien_prarie_1.png', 'quality': 0},
'alien world 1': {'file': 'images/prerendered/alien_world_1.png', 'thumbnail': 'images/prerendered/th/alien_world_1.png', 'quality': 3},
'alien world 2': {'file': 'images/prerendered/alien_world_2.png', 'thumbnail': 'images/prerendered/th/alien_world_2.png', 'quality': 3},
'alien world 3': {'file': 'images/prerendered/alien_world_3.png', 'thumbnail': 'images/prerendered/th/alien_world_3.png', 'quality': 3},
'alien world 4': {'file': 'images/prerendered/alien_world_4.png', 'thumbnail': 'images/prerendered/th/alien_world_4.png', 'quality': 3},
'alien world 5': {'file': 'images/prerendered/alien_world_5.png', 'thumbnail': 'images/prerendered/th/alien_world_5.png', 'quality': 3},
'BurntCity': {'file': 'images/prerendered/BurntCity.png', 'thumbnail': 'images/prerendered/th/BurntCity.png', 'quality': 2},
'canyon water 1': {'file': 'images/prerendered/canyon_water_1.png', 'thumbnail': 'images/prerendered/th/canyon_water_1.png', 'quality': 0},
'CONQ Caustic Valley': {'file': 'images/prerendered/CONQ_Caustic_Valley.png', 'thumbnail': 'images/prerendered/th/CONQ_Caustic_Valley.png', 'quality': 2},
'CONQ Frozen City': {'file': 'images/prerendered/CONQ_Frozen_City.png', 'thumbnail': 'images/prerendered/th/CONQ_Frozen_City.png', 'quality': 1},
'CONQ Hellebore Springs': {'file': 'images/prerendered/CONQ_Hellebore_Springs.png', 'thumbnail': 'images/prerendered/th/CONQ_Hellebore_Springs.png', 'quality': 2},
'CONQ Terra Therma': {'file': 'images/prerendered/CONQ_Terra_Therma.png', 'thumbnail': 'images/prerendered/th/CONQ_Terra_Therma.png', 'quality': 1},
'CONQ Viridian Bog': {'file': 'images/prerendered/CONQ_Viridian_Bog.png', 'thumbnail': 'images/prerendered/th/CONQ_Viridian_Bog.png', 'quality': 1},
'cute3dkawaii': {'file': 'images/prerendered/cute3dkawaii.png', 'thumbnail': 'images/prerendered/th/cute3dkawaii.png', 'quality': 0},
'dark dirt elevations 1': {'file': 'images/prerendered/dark_dirt_elevations_1.png', 'thumbnail': 'images/prerendered/th/dark_dirt_elevations_1.png', 'quality': 0},
'donald park': {'file': 'images/prerendered/donald_park.png', 'thumbnail': 'images/prerendered/th/donald_park.png', 'quality': 0},
'elevated peninsula 1': {'file': 'images/prerendered/elevated_peninsula_1.png', 'thumbnail': 'images/prerendered/th/elevated_peninsula_1.png', 'quality': 0},
'Firefly alien canyons 1': {'file': 'images/prerendered/Firefly_alien_canyons_1.png', 'thumbnail': 'images/prerendered/th/Firefly_alien_canyons_1.png', 'quality': 2},
'Firefly alien canyons 2': {'file': 'images/prerendered/Firefly_alien_canyons_2.png', 'thumbnail': 'images/prerendered/th/Firefly_alien_canyons_2.png', 'quality': 3},
'Firefly alien dry canyons 1': {'file': 'images/prerendered/Firefly_alien_dry_canyons_1.png', 'thumbnail': 'images/prerendered/th/Firefly_alien_dry_canyons_1.png', 'quality': 3},
'Firefly alien dry canyons 2': {'file': 'images/prerendered/Firefly_alien_dry_canyons_2.png', 'thumbnail': 'images/prerendered/th/Firefly_alien_dry_canyons_2.png', 'quality': 3},
'Firefly alien map 1': {'file': 'images/prerendered/Firefly_alien_map_1.png', 'thumbnail': 'images/prerendered/th/Firefly_alien_map_1.png', 'quality': 3},
'Firefly hpg terrain 1': {'file': 'images/prerendered/Firefly_hpg_terrain_1.png', 'thumbnail': 'images/prerendered/th/Firefly_hpg_terrain_1.png', 'quality': 1},
'Firefly hpg terrain 2': {'file': 'images/prerendered/Firefly_hpg_terrain_2.png', 'thumbnail': 'images/prerendered/th/Firefly_hpg_terrain_2.png', 'quality': 0},
'Firefly river dry 1': {'file': 'images/prerendered/Firefly_river_dry_1.png', 'thumbnail': 'images/prerendered/th/Firefly_river_dry_1.png', 'quality': 3},
'Firefly river running 1': {'file': 'images/prerendered/Firefly_river_running_1.png', 'thumbnail': 'images/prerendered/th/Firefly_river_running_1.png', 'quality': 3},
'Firefly topographical alien desert 1': {'file': 'images/prerendered/Firefly_topographical_alien_desert_1.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_alien_desert_1.png', 'quality': 3},
'Firefly topographical canyon 1': {'file': 'images/prerendered/Firefly_topographical_canyon_1.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_canyon_1.png', 'quality': 3},
'Firefly topographical height map 1': {'file': 'images/prerendered/Firefly_topographical_height_map_1.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_height_map_1.png', 'quality': 3},
'Firefly topographical height map 2': {'file': 'images/prerendered/Firefly_topographical_height_map_2.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_height_map_2.png', 'quality': 3},
'Firefly topographical height map 3': {'file': 'images/prerendered/Firefly_topographical_height_map_3.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_height_map_3.png', 'quality': 3},
'Firefly topographical height map 5': {'file': 'images/prerendered/Firefly_topographical_height_map_5.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_height_map_5.png', 'quality': 3},
'Firefly topographical height map 6': {'file': 'images/prerendered/Firefly_topographical_height_map_6.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_height_map_6.png', 'quality': 3},
'Firefly topographical marble 1': {'file': 'images/prerendered/Firefly_topographical_marble_1.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_marble_1.png', 'quality': 3},
'Firefly topographical moon 1': {'file': 'images/prerendered/Firefly_topographical_moon_1.png', 'thumbnail': 'images/prerendered/th/Firefly_topographical_moon_1.png', 'quality': 3},
'fractal islands': {'file': 'images/prerendered/fractal_islands.png', 'thumbnail': 'images/prerendered/th/fractal_islands.png', 'quality': 1},
'Genison': {'file': 'images/prerendered/Genison.png', 'thumbnail': 'images/prerendered/th/Genison.png', 'quality': 1},
'green farming alien world 1': {'file': 'images/prerendered/green_farming_alien_world_1.png', 'thumbnail': 'images/prerendered/th/green_farming_alien_world_1.png', 'quality': 3},
'green farming alien world 2': {'file': 'images/prerendered/green_farming_alien_world_2.png', 'thumbnail': 'images/prerendered/th/green_farming_alien_world_2.png', 'quality': 3},
'grey barren alien world 1': {'file': 'images/prerendered/grey_barren_alien_world_1.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_1.png', 'quality': 3},
'grey barren alien world 2': {'file': 'images/prerendered/grey_barren_alien_world_2.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_2.png', 'quality': 3},
'grey barren alien world 3': {'file': 'images/prerendered/grey_barren_alien_world_3.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_3.png', 'quality': 3},
'grey barren alien world 4': {'file': 'images/prerendered/grey_barren_alien_world_4.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_4.png', 'quality': 3},
'grey barren alien world 5': {'file': 'images/prerendered/grey_barren_alien_world_5.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_5.png', 'quality': 3},
'grey barren alien world 6': {'file': 'images/prerendered/grey_barren_alien_world_6.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_6.png', 'quality': 3},
'grey barren alien world 7': {'file': 'images/prerendered/grey_barren_alien_world_7.png', 'thumbnail': 'images/prerendered/th/grey_barren_alien_world_7.png', 'quality': 3},
'grey waterless alien world map': {'file': 'images/prerendered/grey_waterless_alien_world_map.png', 'thumbnail': 'images/prerendered/th/grey_waterless_alien_world_map.png', 'quality': 3},
'grid 1': {'file': 'images/prerendered/grid_1.png', 'thumbnail': 'images/prerendered/th/grid_1.png', 'quality': 0},
'Hex gen map': {'file': 'images/prerendered/Hex_gen_map.png', 'thumbnail': 'images/prerendered/th/Hex_gen_map.png', 'quality': 0},
'hex grass dirty': {'file': 'images/prerendered/hex_grass_dirty.png', 'thumbnail': 'images/prerendered/th/hex_grass_dirty.png', 'quality': 0},
'hex military industrial alien world map': {'file': 'images/prerendered/hex_military_industrial_alien_world_map.png', 'thumbnail': 'images/prerendered/th/hex_military_industrial_alien_world_map.png', 'quality': 3},
'hex mixed elevations battlefield 1': {'file': 'images/prerendered/hex_mixed_elevations_battlefield_1.png', 'thumbnail': 'images/prerendered/th/hex_mixed_elevations_battlefield_1.png', 'quality': 0},
'hex mixed elevations battlefield 2': {'file': 'images/prerendered/hex_mixed_elevations_battlefield_2.png', 'thumbnail': 'images/prerendered/th/hex_mixed_elevations_battlefield_2.png', 'quality': 0},
'hex tree territory': {'file': 'images/prerendered/hex_tree_territory.png', 'thumbnail': 'images/prerendered/th/hex_tree_territory.png', 'quality': 3},
'lake city': {'file': 'images/prerendered/lake_city.png', 'thumbnail': 'images/prerendered/th/lake_city.png', 'quality': 2},
'mickey lagoon': {'file': 'images/prerendered/mickey_lagoon.png', 'thumbnail': 'images/prerendered/th/mickey_lagoon.png', 'quality': 1},
'mixed elevations battlefield 3': {'file': 'images/prerendered/mixed_elevations_battlefield_3.png', 'thumbnail': 'images/prerendered/th/mixed_elevations_battlefield_3.png', 'quality': 0},
'n6W9Hc': {'file': 'images/prerendered/n6W9Hc.png', 'thumbnail': 'images/prerendered/th/n6W9Hc.png', 'quality': 1},
'oasis mixed elevations 1': {'file': 'images/prerendered/oasis_mixed_elevations_1.png', 'thumbnail': 'images/prerendered/th/oasis_mixed_elevations_1.png', 'quality': 0},
'pic526383': {'file': 'images/prerendered/pic526383.png', 'thumbnail': 'images/prerendered/th/pic526383.png', 'quality': 0},
'pinecone islands': {'file': 'images/prerendered/pinecone_islands.png', 'thumbnail': 'images/prerendered/th/pinecone_islands.png', 'quality': 1},
'purple pines': {'file': 'images/prerendered/purple_pines.png', 'thumbnail': 'images/prerendered/th/purple_pines.png', 'quality': 0},
'red volcanic alien 1': {'file': 'images/prerendered/red_volcanic_alien_1.png', 'thumbnail': 'images/prerendered/th/red_volcanic_alien_1.png', 'quality': 3},
'red volcanic alien 2': {'file': 'images/prerendered/red_volcanic_alien_2.png', 'thumbnail': 'images/prerendered/th/red_volcanic_alien_2.png', 'quality': 3},
'red volcanic alien 3': {'file': 'images/prerendered/red_volcanic_alien_3.png', 'thumbnail': 'images/prerendered/th/red_volcanic_alien_3.png', 'quality': 3},
'red volcanic alien 4': {'file': 'images/prerendered/red_volcanic_alien_4.png', 'thumbnail': 'images/prerendered/th/red_volcanic_alien_4.png', 'quality': 3},
'roadway 1': {'file': 'images/prerendered/roadway_1.png', 'thumbnail': 'images/prerendered/th/roadway_1.png', 'quality': 0},
'snowy lake': {'file': 'images/prerendered/snowy_lake.png', 'thumbnail': 'images/prerendered/th/snowy_lake.png', 'quality': 0},
'snowy rolling hills 1': {'file': 'images/prerendered/snowy_rolling_hills_1.png', 'thumbnail': 'images/prerendered/th/snowy_rolling_hills_1.png', 'quality': 0},
'volcanic alien world map': {'file': 'images/prerendered/volcanic_alien_world_map.png', 'thumbnail': 'images/prerendered/th/volcanic_alien_world_map.png', 'quality': 3},
'war torn post apocalyptic alien world map': {'file': 'images/prerendered/war_torn_post_apocalyptic_alien_world_map.png', 'thumbnail': 'images/prerendered/th/war_torn_post_apocalyptic_alien_world_map.png', 'quality': 3},
}
pre_rendered_maps_paths = [
map_file['file'].replace("\\", "/")
for map_name, map_file in sorted(
PRE_RENDERED_MAPS_JSON_LEVELS.items(),
key=lambda x: (
x[1]['quality'],
''.join(char.lower() for char in x[0] if char.isalnum())
)
)
]
pre_rendered_maps_paths_api_file = [f"./gradio_api/file={map_path}" for map_path in pre_rendered_maps_paths]
# Available FLUX model names
MODELS = [
"black-forest-labs/FLUX.1-schnell",
"black-forest-labs/FLUX.1-dev",
"ostris/Flex.1-alpha",
"black-forest-labs/FLUX.1-Fill-dev"
]
# Available LoRA weights
LORA_WEIGHTS = [
"Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design",
"Shakker-Labs/FLUX.1-dev-LoRA-Micro-landscape-on-Mobile-Phone",
"Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1",
"Cossale/Frames2-Flex.1",
"AlekseyCalvin/HSTcolorFlexAlpha",
"XLabs-AI/flux-lora-collection/anime_lora.safetensors",
"XLabs-AI/flux-lora-collection/scenery_lora.safetensors",
"XLabs-AI/flux-lora-collection/disney_lora.safetensors",
"XLabs-AI/flux-RealismLora",
"strangerzonehf/Flux-Cute-3D-Kawaii-LoRA",
"SebastianBodza/flux_cute3D",
"gokaygokay/Flux-Seamless-Texture-LoRA",
"gokaygokay/Flux-Game-Assets-LoRA-v2",
"lrzjason/ObjectRemovalFluxFill",
]
# 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",
"Shakker-Labs/FLUX.1-dev-LoRA-Micro-landscape-on-Mobile-Phone": "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",
"XLabs-AI/flux-RealismLora":"black-forest-labs/FLUX.1-dev",
"strangerzonehf/Flux-Cute-3D-Kawaii-LoRA":"black-forest-labs/FLUX.1-dev",
"SebastianBodza/flux_cute3D":"black-forest-labs/FLUX.1-dev",
"gokaygokay/Flux-Seamless-Texture-LoRA":"black-forest-labs/FLUX.1-dev",
"gokaygokay/Flux-Game-Assets-LoRA-v2":"black-forest-labs/FLUX.1-dev",
"lrzjason/ObjectRemovalFluxFill":"black-forest-labs/FLUX.1-Fill-dev",
}
condition_type = ["depth", "canny", "subject", "coloring", "deblurring", "fill", "redux"]
# Detailed LoRA weight configurations
LORA_DETAILS = {
"AlekseyCalvin/HSTcolorFlexAlpha" : [
{
"trigger_words": "(6kStepsCkpt)HST style analog autochrome photo ",
},
{
"weight_name": "HSToricColorFlex_6000steps_LoRAforFluxOrFlex_32dim64alpha.safetensors",
},
{
"notes": "We use (6kStepsCkpt)HST style analog autochrome photo as trigger words."
},
{
"title": "HSToric Color Flex",
},
{
"parameters" :{
"num_inference_steps": "30"
}
},
{
"thumbnail": "https://huggingface.co/AlekseyCalvin/HSTcolorFlexAlpha/resolve/main/images/example_gypubjtqx.png",
"show_in_gallery": True
}
],
"XLabs-AI/flux-lora-collection/anime_lora.safetensors":[
{
"lora_collection": "XLabs-AI/flux-lora-collection",
"weight_name": "anime_lora.safetensors"
},
{
"trigger_words": "anime,",
},
{
"title": "Anime",
},
{
"notes": "You should use ',anime' as trigger words at the end. "
},
{
"parameters" :{
"num_inference_steps": "30"
}
},
{
"thumbnail": "https://github.com/XLabs-AI/x-flux/blob/main/assets/readme/examples/result_14.png?raw=true",
"show_in_gallery": True
}
],
"XLabs-AI/flux-lora-collection/scenery_lora.safetensors":[
{
"lora_collection": "XLabs-AI/flux-lora-collection",
"weight_name": "scenery_lora.safetensors"
},
{
"trigger_words": "scenery style,",
},
{
"title": "Scenery",
},
{
"notes": "You should use ',scenery style' as trigger words at the end. "
},
{
"parameters" :{
"num_inference_steps": "30"
}
},
{
"thumbnail": "https://github.com/XLabs-AI/x-flux/blob/main/assets/readme/examples/result_21.png?raw=true",
"show_in_gallery": True
}
],
"XLabs-AI/flux-lora-collection/disney_lora.safetensors":[
{
"lora_collection": "XLabs-AI/flux-lora-collection",
"weight_name": "disney_lora.safetensors"
},
{
"trigger_words": "disney style,",
},
{
"title": "Disney Style",
},
{
"notes": "You should use ',disney style' as trigger words at the end. "
},
{
"parameters" :{
"num_inference_steps": "30"
}
},
{
"thumbnail": "https://github.com/XLabs-AI/x-flux/blob/main/assets/readme/examples/result_19.png?raw=true",
"show_in_gallery": True
}
],
"XLabs-AI/flux-RealismLora":[
{
"notes": "No trigger words but 8k, Animatrix illustration style, fantasy style, natural photo cinematic should all work "
},
{
"title": "Realism",
},
{
"parameters" :{
"guidance_scale": "3.2",
"num_inference_steps": "34",
"scale": "0.85"
}
},
{
"thumbnail": "https://huggingface.co/VideoAditor/Flux-Lora-Realism/resolve/main/images/feel-the-difference-between-using-flux-with-lora-from-xlab-v0-j0ehybmvxehd1.png",
"show_in_gallery": True
}
],
"Cossale/Frames2-Flex.1": [
{
"weight_name": "backdrops_v2.safetensors",
"adapter_name": "backdrops_v2"
},
{
"trigger_words": "FRM$",
},
{
"title": "Frames2-Flex.1",
},
{
"notes": " FRM$ used as trigger words. "
},
{
"parameters" :{
"num_inference_steps": "50"
}
},
{
"thumbnail": "https://huggingface.co/Cossale/Frames2-Flex.1/resolve/main/samples/1737567472380__000005000_2.jpg",
"show_in_gallery": True
}
],
"Yuanshi/OminiControl": [
{
"weight_name": "omini/subject_512.safetensors",
"adapter_name": "subject_512"
},
{
"weight_name": "omini/subject_1024_beta.safetensors",
"adapter_name": "subject_1024"
},
{
"trigger_words": "omini,",
},
{
"parameters" :{
"num_inference_steps": "8",
"guidance_scale": "0"
}
},
{
"notes": "Select an Image as a guide."
},
{
"thumbnail": "",
"show_in_gallery": False
}
],
"Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design": [
{
"notes": "Uses wablogo, logo, Minimalist as trigger words.."
},
{
"trigger_words": "wablogo, logo, Minimalist ",
},
{
"title": "Logo Design",
},
{
"pipe" :{
"fuse_lora": {"lora_scale":0.8}
}
},
{
"parameters" :{
"num_inference_steps": "38"
}
},
{
"thumbnail": "https://huggingface.co/Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design/resolve/main/images/73e7db6a33550d05836ce285549de60075d05373c7b0660d631dac33.jpg",
"show_in_gallery": True
}
],
"Shakker-Labs/FLUX.1-dev-LoRA-Micro-landscape-on-Mobile-Phone": [
{
"notes": "Uses miniature stereoscopic scene as trigger words.."
},
{
"trigger_words": "miniature stereoscopic scene ",
},
{
"title": "Micro Landscape",
},
{
"weight_name": "FLUX-dev-lora-micro-landscape.safetensors",
},
{
"pipe" :{
"fuse_lora": {"lora_scale":0.7}
}
},
{
"parameters" :{
"guidance_scale": "3.5",
"num_inference_steps": "24",
"scale": "0.72",
}
},
{
"thumbnail": "https://huggingface.co/Shakker-Labs/FLUX.1-dev-LoRA-Micro-landscape-on-Mobile-Phone/resolve/main/images/c4f5c765bc8d3d396ed13d65666895ab23ada35c78ca6d91bf814613.jpg",
"show_in_gallery": True
}
],
"Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1": [
{
"notes": "Uses fractalLand at the start of the prompts to activate the fractal elements. . "
},
{
"trigger_words": "fractalLand ",
},
{
"title": "fractalLand",
},
{
"parameters" :{
"max_sequence_length": "512",
"guidance_scale": "3.5",
"num_inference_steps": "38"
}
},
{
"thumbnail": "https://huggingface.co/Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1/resolve/main/images/example_e2zoqwftv.png",
"show_in_gallery": True
}
],
"strangerzonehf/Flux-Cute-3D-Kawaii-LoRA": [
{
"weight_name": "Cute-3d-Kawaii.safetensors",
},
{
"notes": "Uses Cute 3d Kawaii at the start of the prompts "
},
{
"trigger_words": "Cute 3d Kawaii ",
},
{
"title": "Cute 3D Kawaii",
},
{
"parameters" :{
"height": "1024"
}
},
{
"thumbnail": "https://huggingface.co/strangerzonehf/Flux-Cute-3D-Kawaii-LoRA/resolve/main/images/CK3.png",
"show_in_gallery": True
}
],
"SebastianBodza/flux_cute3D": [
{
"notes": "Uses NEOCUTE3D at the start of the prompts "
},
{
"trigger_words": "NEOCUTE3D ",
},
{
"title": "Cute 3D",
},
{
"thumbnail": "https://huggingface.co/SebastianBodza/flux_cute3D/resolve/main/images/astronaut.webp",
"show_in_gallery": True
}
],
"gokaygokay/Flux-Seamless-Texture-LoRA": [
{
"notes": "Uses smlstxtr at the start of the prompts "
},
{
"weight_name": "seamless_texture.safetensors",
},
{
"trigger_words": "smlstxtr ",
},
{
"title": "Seamless Texture",
},
{
"thumbnail": "https://huggingface.co/gokaygokay/Flux-Seamless-Texture-LoRA/resolve/main/images/image3.jpg",
"show_in_gallery": True
}
],
"gokaygokay/Flux-Game-Assets-LoRA-v2": [
{
"notes": "Uses wbgmsst, white background at the start of the prompts "
},
{
"trigger_words": "wbgmsst, white background ",
},
{
"title": "Game Assets",
},
{
"thumbnail": "https://huggingface.co/gokaygokay/Flux-Game-Assets-LoRA-v2/resolve/main/images/example_y2bqpuphc.png",
"show_in_gallery": True
}
],
"lrzjason/ObjectRemovalFluxFill":[
{
"notes": "Used to remove objects, may leave a blur "
},
{
"weight_name": "objectRemovalv1_r32.safetensors",
},
{
"title": "Object Removal",
},
{
"parameters" :{
"guidance_scale": "30",
"num_inference_steps": "50",
"max_sequence_length": "512"
}
},
{
"thumbnail": "images/prerendered/th/object_removal.png",
"show_in_gallery": False
}
],
}
def sort_loras(sortby):
loras = []
for key, details in LORA_DETAILS.items():
lora_info = {
"image": "",
"title": "",
"repo": key,
"weights": "",
"trigger_word": "",
"notes": ""
}
for item in details:
if "thumbnail" in item:
lora_info["image"] = item.get("thumbnail", "")
if "weight_name" in item:
lora_info["weights"] = item.get("weight_name", "")
if "trigger_words" in item:
lora_info["trigger_word"] = item.get("trigger_words", "")
if "notes" in item:
lora_info["notes"] = item.get("notes", "")
if "title" in item:
lora_info["title"] = item.get("title", "")
# Default title to key if not provided
if not lora_info["title"]:
lora_info["title"] = key
# Only add to gallery if flagged "show_in_gallery" = True
if any(item.get("show_in_gallery", False) for item in details):
if lora_info["image"] == "":
lora_info["image"] = "images/Beeuty-1.png"
loras.append(lora_info)
# Add models from the MODELS list with a default thumbnail
for model in MODELS:
loras.append({
"image": f"images/prerendered/th/"+ model.split("/")[-1]+".png",
"title": model.split("/")[-1],
"repo": model,
"weights": "",
"trigger_word": "",
"notes": ""
})
# Sort the loras list by the title attribute
loras = sorted(loras, key=lambda x: x[sortby])
loras.append({
"image": f"images/images/Bee-test-2.png",
"title": "Manual Entry",
"repo": "Manual Entry",
"weights": "",
"trigger_word": "",
"notes": ""
})
return loras
LORAS = sort_loras("title")
# Read the contents of the LUT folder, output to a list
lut_folder = "./LUT"
lut_files = [os.path.join(lut_folder, f).replace("\\", "/") for f in os.listdir(lut_folder) if f.endswith(".cube")]
temp_files = []
cards = [
"2♥️", "3♥️", "4♥️", "5♥️", "6♥️", "7♥️", "8♥️", "9♥️", "10♥️", "J♥️", "Q♥️", "K♥️", "A♥️",
"2♦️", "3♦️", "4♦️", "5♦️", "6♦️", "7♦️", "8♦️", "9♦️", "10♦️", "J♦️", "Q♦️", "K♦️", "A♦️",
"2♣️", "3♣️", "4♣️", "5♣️", "6♣️", "7♣️", "8♣️", "9♣️", "10♣️", "J♣️", "Q♣️", "K♣️", "A♣️",
"2♠️", "3♠️", "4♠️", "5♠️", "6♠️", "7♠️", "8♠️", "9♠️", "10♠️", "J♠️", "Q♠️", "K♠️", "A♠️"
]
cards_alternating = [
"2♥️", "3♥️", "4♥️", "5♥️", "6♥️", "7♥️", "8♥️", "9♥️", "10♥️", "J♥️", "Q♥️", "K♥️", "A♥️",
"2♣️", "3♣️", "4♣️", "5♣️", "6♣️", "7♣️", "8♣️", "9♣️", "10♣️", "J♣️", "Q♣️", "K♣️", "A♣️",
"2♦️", "3♦️", "4♦️", "5♦️", "6♦️", "7♦️", "8♦️", "9♦️", "10♦️", "J♦️", "Q♦️", "K♦️", "A♦️",
"2♠️", "3♠️", "4♠️", "5♠️", "6♠️", "7♠️", "8♠️", "9♠️", "10♠️", "J♠️", "Q♠️", "K♠️", "A♠️"
]
card_colors = [
"#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", # Hearts
"#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", # Diamonds
"#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", # Clubs
"#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000" # Spades
]
card_colors_alternating = [
"#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", # Hearts
"#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", # Clubs
"#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000", # Diamonds
"#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000" # Spades
]