Spaces:
Running on Zero
Running on Zero
File size: 1,683 Bytes
f0d9a3e 4bb998d f0d9a3e 4bb998d f0d9a3e fe203b8 f0d9a3e | 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 | """Centralized configuration settings for the application."""
import os
from pathlib import Path
from typing import Optional
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Base paths
BASE_DIR = Path(__file__).parent.parent
# HF Spaces: use persistent storage when available (/data). Fallback to repo-local.
_PERSISTENT_ROOT = Path("/data")
_DEFAULT_OUTPUT_ROOT = _PERSISTENT_ROOT if _PERSISTENT_ROOT.exists() else BASE_DIR
OUTPUT_DIR = _DEFAULT_OUTPUT_ROOT / os.getenv("OUTPUT_DIR", "generated_images")
ASSETS_DIR = BASE_DIR / os.getenv("ASSETS_DIR", "assets")
EXAMPLES_DIR = ASSETS_DIR / "examples"
# Model configuration
# For HF Inference / InferenceClient, prefer the canonical repo id (no "models/").
MODEL_ID = os.getenv("MODEL_ID", "gokaygokay/Flux-Seamless-Texture-LoRA")
MODEL_PROVIDER = os.getenv("MODEL_PROVIDER", "hf-inference")
# MCP configuration
MCP_ENABLED = True
MCP_ENDPOINT = "/gradio_api/mcp/"
# Application settings
MAX_IMAGES = int(os.getenv("MAX_IMAGES", "100"))
CLEANUP_AFTER_DAYS = int(os.getenv("CLEANUP_AFTER_DAYS", "7"))
ENABLE_WATERMARK = os.getenv("ENABLE_WATERMARK", "false").lower() == "true"
# Logging
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
LOG_FILE = os.getenv("LOG_FILE", "app.log")
# Default generation parameters
DEFAULT_PARAMS = {
"guidance_scale": 7.5,
"num_inference_steps": 50,
"seed": None,
"width": 1024,
"height": 1024,
"cfg_scale": 7.5,
"negative_prompt": "",
"lora_strength": 1.0,
}
# Create directories if they don't exist
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
ASSETS_DIR.mkdir(parents=True, exist_ok=True)
EXAMPLES_DIR.mkdir(parents=True, exist_ok=True)
|