Muhammad commited on
Update src/config.py
Browse files123344566789101112789101112131415161718192021222324252627161718282930313233343536import osfrom pathlib import Path
# The root directory on Hugging Face is /appBASE_DIR = Path("/app")# 1. Define the base directory as the root of your projectBASE_DIR = Path(__file__).resolve().parent.parent
# Existing pathsMODEL_PATH = BASE_DIR / "GardCom" / "saved_models_run2" / "best_model.keras"CLASS_MAP_PATH = BASE_DIR / "GardCom" / "saved_models_run2" / "class_map.json"
# ADD THIS LINE TO FIX THE ERROR# Usually, this points to a JSON or CSV file with training metricsTRAINING_SUMMARY_PATH = BASE_DIR / "GardCom" / "saved_models_run2" / "training_log.json" # 2. Function to find the model path dynamicallydef find_path(filename): # Potential locations: Root, inside GardCom, or inside src options = [ BASE_DIR / "saved_models_run2" / filename, BASE_DIR / "GardCom" / "saved_models_run2" / filename, BASE_DIR / "src" / "saved_models_run2" / filename ] for path in options: if path.exists(): return path # Return the most likely path as default if none exist (to avoid import errors) return options[0]
# 3. Assign pathsMODEL_PATH = find_path("best_model.keras")CLASS_MAP_PATH = find_path("class_map.json")TRAINING_SUMMARY_PATH = find_path("training_log.json") # Added to avoid the previous ImportError
# Standard constantsIMAGE_SIZE = (224, 224)OOD_THRESHOLD = 0.70TOP_K_DEFAULT = 5MAX_CONTENT_LENGTH = 16 * 1024 * 1024OOD_THRESHOLD = 0.35TOP_K_DEFAULT = 3
# Log the found path to the console so you can see it in HF Logsprint(f"--- CONFIG LOADED ---")print(f"MODEL_PATH: {MODEL_PATH} (Exists: {MODEL_PATH.exists()})")
# Change this in your HF Space config.pyFLASK_PORT = 7860 # Hugging Face requirementsrc/config.py+27-12