Spaces:
Running
Running
| /** | |
| * Application Configuration | |
| * Contains all configuration constants for the ONNX Model Explorer | |
| */ | |
| const CONFIG = { | |
| // Application Info | |
| APP_NAME: 'ONNX Model Explorer', | |
| APP_VERSION: '1.0.0', | |
| // Paths | |
| MODELS_PATH: './models/', | |
| MODELS_CONFIG_FILE: './models/models.json', | |
| // CDN URLs | |
| CDN: { | |
| PROTOBUF_JS: 'https://cdn.jsdelivr.net/npm/protobufjs@7/dist/protobuf.min.js', | |
| CYTOSCAPE_JS: 'https://cdn.jsdelivr.net/npm/cytoscape@latest/dist/cytoscape.min.js', | |
| BOOTSTRAP_CSS: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css', | |
| BOOTSTRAP_JS: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js', | |
| FONT_AWESOME: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css' | |
| }, | |
| // File Configuration | |
| FILE: { | |
| ALLOWED_EXTENSIONS: ['.onnx', '.safetensors', '.tflite', '.h5', '.keras', '.pb', '.mlmodel', '.caffemodel', '.weights', '.pdmodel', '.params'], | |
| MAX_FILE_SIZE: Infinity, // No file size limit | |
| UPLOAD_TIMEOUT: 30000 // 30 seconds | |
| }, | |
| // UI Configuration | |
| UI: { | |
| MODEL_LIST_MAX_HEIGHT: 600, | |
| GRAPH_CONTAINER_HEIGHT: 500, | |
| SEARCH_DEBOUNCE_DELAY: 300, | |
| ERROR_DISPLAY_DURATION: 5000, // 5 seconds | |
| LOADING_SPINNER_DELAY: 500 // 0.5 seconds | |
| }, | |
| // Graph Configuration | |
| GRAPH: { | |
| DEFAULT_ZOOM: 1, | |
| MIN_ZOOM: 0.1, | |
| MAX_ZOOM: 5, | |
| ZOOM_STEP: 0.1, | |
| NODE_HIGHLIGHT_COLOR: '#FFD700', | |
| NODE_DEFAULT_COLOR: '#87CEEB', | |
| EDGE_DEFAULT_COLOR: '#999' | |
| }, | |
| // Performance Configuration | |
| PERFORMANCE: { | |
| LAZY_LOAD_THRESHOLD: 1000, // Load graphs with > 1000 nodes lazily | |
| CACHE_SIZE: 10, // Number of models to cache | |
| BATCH_RENDER_SIZE: 100 // Number of nodes to render per batch | |
| }, | |
| // Error Messages | |
| ERRORS: { | |
| FILE_NOT_FOUND: 'File not found. Please check the file path.', | |
| INVALID_FILE_FORMAT: 'Invalid file format. Please upload a valid ONNX (.onnx), SafeTensors (.safetensors), TFLite (.tflite), or other supported model file.', | |
| PARSE_ERROR: 'Failed to parse the model. The file may be corrupted.', | |
| LIBRARY_LOAD_ERROR: 'Failed to load required libraries. Please check your internet connection.', | |
| UPLOAD_ERROR: 'Failed to upload the file. Please try again.', | |
| EXPORT_ERROR: 'Failed to export the model information.', | |
| UNKNOWN_ERROR: 'An unknown error occurred. Please try again.', | |
| NO_MODELS_AVAILABLE: 'No models available. Please upload an ONNX file.', | |
| MODEL_LOAD_TIMEOUT: 'Model loading timed out. Please try again.', | |
| INVALID_MODEL_DATA: 'Invalid model data. The model may be corrupted.' | |
| }, | |
| // Success Messages | |
| SUCCESS: { | |
| MODEL_LOADED: 'Model loaded successfully.', | |
| FILE_UPLOADED: 'File uploaded successfully.', | |
| MODEL_EXPORTED: 'Model exported successfully.', | |
| SEARCH_COMPLETED: 'Search completed.' | |
| }, | |
| // Info Messages | |
| INFO: { | |
| LOADING_MODEL: 'Loading model...', | |
| PARSING_MODEL: 'Parsing model...', | |
| RENDERING_GRAPH: 'Rendering graph...', | |
| SEARCHING: 'Searching...' | |
| }, | |
| // Data Type Mapping | |
| DATA_TYPES: { | |
| 1: 'FLOAT', | |
| 2: 'UINT8', | |
| 3: 'INT8', | |
| 4: 'UINT16', | |
| 5: 'INT16', | |
| 6: 'INT32', | |
| 7: 'INT64', | |
| 8: 'STRING', | |
| 9: 'BOOL', | |
| 10: 'FLOAT16', | |
| 11: 'DOUBLE', | |
| 12: 'UINT32', | |
| 13: 'UINT64', | |
| 14: 'COMPLEX64', | |
| 15: 'COMPLEX128', | |
| 16: 'BFLOAT16' | |
| }, | |
| // Local Storage Keys | |
| STORAGE: { | |
| SELECTED_MODEL: 'onnx_explorer_selected_model', | |
| RECENT_MODELS: 'onnx_explorer_recent_models', | |
| USER_PREFERENCES: 'onnx_explorer_preferences', | |
| CACHE_PREFIX: 'onnx_explorer_cache_' | |
| }, | |
| // Event Names | |
| EVENTS: { | |
| MODEL_LOADED: 'model:loaded', | |
| MODEL_SELECTED: 'model:selected', | |
| NODE_SELECTED: 'node:selected', | |
| SEARCH_UPDATED: 'search:updated', | |
| ERROR_OCCURRED: 'error:occurred', | |
| EXPORT_REQUESTED: 'export:requested', | |
| COMPARISON_STARTED: 'comparison:started', | |
| COMPARISON_ENDED: 'comparison:ended', | |
| FILE_UPLOADED: 'file:uploaded', | |
| GRAPH_RENDERED: 'graph:rendered' | |
| }, | |
| // Logging Configuration | |
| LOGGING: { | |
| ENABLED: true, | |
| LEVEL: 'info', // 'debug', 'info', 'warn', 'error' | |
| CONSOLE_OUTPUT: true | |
| } | |
| }; | |
| // Freeze the config object to prevent modifications | |
| Object.freeze(CONFIG); | |