File size: 4,666 Bytes
9bd422a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
 * 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);