yasai-api-light / add_debug.js
tabito12345678910
Fix age range handling and model architecture
eb9bda6
const fs = require('fs');
// Read the file
let content = fs.readFileSync('app.py', 'utf8');
// Add more detailed debugging for model loading
content = content.replace(
'if model_files_exist:',
'if model_files_exist:\n print(f"πŸ” Checking model files:")\n print(f" - MODEL_PATH: {MODEL_PATH} (exists: {os.path.exists(MODEL_PATH)})")\n print(f" - ENCODERS_DIR: {ENCODERS_DIR} (exists: {os.path.exists(ENCODERS_DIR)})")\n print(f" - PRODUCT_MASTER_PATH: {PRODUCT_MASTER_PATH} (exists: {os.path.exists(PRODUCT_MASTER_PATH)})")\n \n # Check file sizes\n if os.path.exists(MODEL_PATH):\n model_size = os.path.getsize(MODEL_PATH) / (1024*1024) # MB\n print(f" - Model file size: {model_size:.2f} MB")\n \n if os.path.exists(ENCODERS_DIR):\n encoder_files = [f for f in os.listdir(ENCODERS_DIR) if f.endswith(".json")]\n print(f" - Encoder files found: {encoder_files}")'
);
// Add more detailed error logging in the exception handler
content = content.replace(
' except Exception as e:\n print(f"❌ Failed to load Yasai CID model: {e}")',
' except Exception as e:\n print(f"❌ Failed to load Yasai CID model: {e}")\n import traceback\n print(f"❌ Full traceback: {traceback.format_exc()}")'
);
// Write the updated content back
fs.writeFileSync('app.py', content);
console.log('Successfully added debugging information to app.py');