wuhp commited on
Commit
a1cf3ed
·
verified ·
1 Parent(s): 000e826

Update constants.ts

Browse files
Files changed (1) hide show
  1. constants.ts +228 -2
constants.ts CHANGED
@@ -1,3 +1,4 @@
 
1
  import { LayerDefinition, LayerType, GraphTemplate } from './types';
2
 
3
  export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
@@ -8,7 +9,7 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
8
  description: 'Entry point for data tensors',
9
  category: 'Core',
10
  parameters: [
11
- { name: 'modality', type: 'select', label: 'Modality', default: 'Tensor', options: ['Tensor', 'Image', 'Text', 'Audio', 'Video', 'Latent', 'State', '3D Volume'] },
12
  { name: 'shape', type: 'string', label: 'Shape (e.g. 3,224,224)', default: '3, 224, 224' },
13
  { name: 'batch_size', type: 'number', label: 'Batch Size', default: 32 },
14
  { name: 'dtype', type: 'select', label: 'Data Type', default: 'float32', options: ['float32', 'int64', 'bool'] }
@@ -58,6 +59,139 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
58
  ]
59
  },
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  // --- MERGE ---
62
  [LayerType.CONCAT]: {
63
  type: LayerType.CONCAT,
@@ -493,6 +627,17 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
493
  { name: 'dropout', type: 'number', label: 'Dropout', default: 0.1 }
494
  ]
495
  },
 
 
 
 
 
 
 
 
 
 
 
496
  [LayerType.TRANSFORMER_ENCODER]: {
497
  type: LayerType.TRANSFORMER_ENCODER,
498
  label: 'Encoder Layer',
@@ -558,6 +703,87 @@ export const INITIAL_EDGES = [
558
  ];
559
 
560
  export const TEMPLATES: Record<string, GraphTemplate> = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  'gpt_style': {
562
  id: 'gpt_style',
563
  name: 'LLM (GPT Style)',
@@ -778,4 +1004,4 @@ export const TEMPLATES: Record<string, GraphTemplate> = {
778
  { id: '4', source: 'cat', target: 'unet' }, { id: '5', source: 'unet', target: 'out' }
779
  ]
780
  }
781
- };
 
1
+
2
  import { LayerDefinition, LayerType, GraphTemplate } from './types';
3
 
4
  export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
 
9
  description: 'Entry point for data tensors',
10
  category: 'Core',
11
  parameters: [
12
+ { name: 'modality', type: 'select', label: 'Modality', default: 'Tensor', options: ['Tensor', 'Image', 'Text', 'Audio', 'Video', 'Latent', 'State', '3D Volume', 'Point Cloud'] },
13
  { name: 'shape', type: 'string', label: 'Shape (e.g. 3,224,224)', default: '3, 224, 224' },
14
  { name: 'batch_size', type: 'number', label: 'Batch Size', default: 32 },
15
  { name: 'dtype', type: 'select', label: 'Data Type', default: 'float32', options: ['float32', 'int64', 'bool'] }
 
59
  ]
60
  },
61
 
62
+ // --- DETECTION (YOLO) ---
63
+ [LayerType.C2F_BLOCK]: {
64
+ type: LayerType.C2F_BLOCK,
65
+ label: 'C2f Block (YOLO)',
66
+ description: 'CSP Bottleneck with 2 convolutions',
67
+ category: 'Detection',
68
+ parameters: [
69
+ { name: 'c1', type: 'number', label: 'In Channels', default: 64 },
70
+ { name: 'c2', type: 'number', label: 'Out Channels', default: 64 },
71
+ { name: 'n', type: 'number', label: 'Num Bottlenecks', default: 1 },
72
+ { name: 'shortcut', type: 'boolean', label: 'Shortcut', default: true }
73
+ ]
74
+ },
75
+ [LayerType.SPPF_BLOCK]: {
76
+ type: LayerType.SPPF_BLOCK,
77
+ label: 'SPPF Block',
78
+ description: 'Spatial Pyramid Pooling - Fast',
79
+ category: 'Detection',
80
+ parameters: [
81
+ { name: 'c1', type: 'number', label: 'In Channels', default: 512 },
82
+ { name: 'c2', type: 'number', label: 'Out Channels', default: 512 },
83
+ { name: 'k', type: 'number', label: 'Kernel Size', default: 5 }
84
+ ]
85
+ },
86
+ [LayerType.DETECT_HEAD]: {
87
+ type: LayerType.DETECT_HEAD,
88
+ label: 'Detection Head',
89
+ description: 'Predicts BBoxes and Classes',
90
+ category: 'Detection',
91
+ parameters: [
92
+ { name: 'nc', type: 'number', label: 'Num Classes', default: 80 },
93
+ { name: 'ch', type: 'text', label: 'Input Channels', default: '()', description: "List of channels from backbone levels" }
94
+ ]
95
+ },
96
+ [LayerType.ANCHOR_BOX]: {
97
+ type: LayerType.ANCHOR_BOX,
98
+ label: 'Anchor Boxes',
99
+ description: 'Reference boxes for detection',
100
+ category: 'Detection',
101
+ parameters: [
102
+ { name: 'aspect_ratios', type: 'text', label: 'Ratios', default: '[0.5, 1.0, 2.0]' },
103
+ { name: 'scales', type: 'text', label: 'Scales', default: '[32, 64, 128]' }
104
+ ]
105
+ },
106
+
107
+ // --- AUDIO / SPEECH ---
108
+ [LayerType.MEL_SPECTROGRAM]: {
109
+ type: LayerType.MEL_SPECTROGRAM,
110
+ label: 'MelSpectrogram',
111
+ description: 'Raw Audio to Mel Spectrogram',
112
+ category: 'Audio',
113
+ parameters: [
114
+ { name: 'sample_rate', type: 'number', label: 'Sample Rate', default: 22050 },
115
+ { name: 'n_fft', type: 'number', label: 'N_FFT', default: 1024 },
116
+ { name: 'n_mels', type: 'number', label: 'Num Mels', default: 80 }
117
+ ]
118
+ },
119
+ [LayerType.CONFORMER_BLOCK]: {
120
+ type: LayerType.CONFORMER_BLOCK,
121
+ label: 'Conformer Block',
122
+ description: 'Convolution + Transformer (ASR)',
123
+ category: 'Audio',
124
+ parameters: [
125
+ { name: 'd_model', type: 'number', label: 'D Model', default: 256 },
126
+ { name: 'nhead', type: 'number', label: 'Heads', default: 4 },
127
+ { name: 'kernel_size', type: 'number', label: 'Conv Kernel', default: 31 }
128
+ ]
129
+ },
130
+ [LayerType.WAVENET_BLOCK]: {
131
+ type: LayerType.WAVENET_BLOCK,
132
+ label: 'WaveNet Block',
133
+ description: 'Dilated Causal Convolution',
134
+ category: 'Audio',
135
+ parameters: [
136
+ { name: 'channels', type: 'number', label: 'Channels', default: 64 },
137
+ { name: 'dilation', type: 'number', label: 'Dilation', default: 1 },
138
+ { name: 'kernel_size', type: 'number', label: 'Kernel', default: 3 }
139
+ ]
140
+ },
141
+ [LayerType.VOCODER]: {
142
+ type: LayerType.VOCODER,
143
+ label: 'Vocoder',
144
+ description: 'Mel Spectrogram to Waveform',
145
+ category: 'Audio',
146
+ parameters: [
147
+ { name: 'type', type: 'select', label: 'Type', default: 'HiFiGAN', options: ['HiFiGAN', 'WaveGlow', 'MelGAN'] },
148
+ { name: 'upsample_rates', type: 'text', label: 'Upsample Rates', default: '[8,8,2,2]' }
149
+ ]
150
+ },
151
+ [LayerType.AUDIO_EMBEDDING]: {
152
+ type: LayerType.AUDIO_EMBEDDING,
153
+ label: 'Audio Embedding',
154
+ description: 'Embeddings for discrete audio tokens',
155
+ category: 'Audio',
156
+ parameters: [
157
+ { name: 'num_embeddings', type: 'number', label: 'Num Embeddings', default: 1024 },
158
+ { name: 'embedding_dim', type: 'number', label: 'Embedding Dim', default: 512 }
159
+ ]
160
+ },
161
+
162
+ // --- 3D / VISION ---
163
+ [LayerType.NERF_BLOCK]: {
164
+ type: LayerType.NERF_BLOCK,
165
+ label: 'NeRF Block',
166
+ description: 'MLP for Radiance Fields',
167
+ category: '3D',
168
+ parameters: [
169
+ { name: 'hidden_dim', type: 'number', label: 'Hidden Dim', default: 256 },
170
+ { name: 'num_layers', type: 'number', label: 'Num Layers', default: 8 },
171
+ { name: 'skips', type: 'text', label: 'Skip Layers', default: '[4]' }
172
+ ]
173
+ },
174
+ [LayerType.POINTNET_BLOCK]: {
175
+ type: LayerType.POINTNET_BLOCK,
176
+ label: 'PointNet Layer',
177
+ description: 'Point cloud feature extraction',
178
+ category: '3D',
179
+ parameters: [
180
+ { name: 'in_channels', type: 'number', label: 'In Channels', default: 3 },
181
+ { name: 'out_channels', type: 'number', label: 'Out Channels', default: 64 }
182
+ ]
183
+ },
184
+ [LayerType.GAUSSIAN_SPLAT]: {
185
+ type: LayerType.GAUSSIAN_SPLAT,
186
+ label: 'Gaussian Splat',
187
+ description: '3D Gaussian Splatting Decoder',
188
+ category: '3D',
189
+ parameters: [
190
+ { name: 'num_gaussians', type: 'number', label: 'Num Gaussians', default: 10000 },
191
+ { name: 'sh_degree', type: 'number', label: 'SH Degree', default: 3 }
192
+ ]
193
+ },
194
+
195
  // --- MERGE ---
196
  [LayerType.CONCAT]: {
197
  type: LayerType.CONCAT,
 
627
  { name: 'dropout', type: 'number', label: 'Dropout', default: 0.1 }
628
  ]
629
  },
630
+ [LayerType.WINDOW_ATTENTION]: {
631
+ type: LayerType.WINDOW_ATTENTION,
632
+ label: 'Window Attention',
633
+ description: 'Sliding/Windowed Attention',
634
+ category: 'Transformer',
635
+ parameters: [
636
+ { name: 'window_size', type: 'number', label: 'Window Size', default: 7 },
637
+ { name: 'embed_dim', type: 'number', label: 'Embed Dim', default: 96 },
638
+ { name: 'num_heads', type: 'number', label: 'Num Heads', default: 4 }
639
+ ]
640
+ },
641
  [LayerType.TRANSFORMER_ENCODER]: {
642
  type: LayerType.TRANSFORMER_ENCODER,
643
  label: 'Encoder Layer',
 
703
  ];
704
 
705
  export const TEMPLATES: Record<string, GraphTemplate> = {
706
+ 'yolo_v8': {
707
+ id: 'yolo_v8',
708
+ name: 'YOLO (Detection)',
709
+ description: 'C2f Backbone with Detection Head.',
710
+ nodes: [
711
+ { id: 'in', type: 'custom', position: {x: 300, y: 0}, data: {label: 'Image', type: LayerType.INPUT, params: {modality: 'Image'}} },
712
+ { id: 'c1', type: 'custom', position: {x: 300, y: 100}, data: {label: 'Conv (Stem)', type: LayerType.CONV2D, params: {out_channels: 64, kernel_size: 3, stride: 2}} },
713
+ { id: 'c2f1', type: 'custom', position: {x: 300, y: 200}, data: {label: 'C2f Block 1', type: LayerType.C2F_BLOCK, params: {c1: 64, c2: 128, n: 3}} },
714
+ { id: 'c2f2', type: 'custom', position: {x: 300, y: 300}, data: {label: 'C2f Block 2', type: LayerType.C2F_BLOCK, params: {c1: 128, c2: 256, n: 6}} },
715
+ { id: 'sppf', type: 'custom', position: {x: 300, y: 400}, data: {label: 'SPPF', type: LayerType.SPPF_BLOCK, params: {c1: 256, c2: 256}} },
716
+ { id: 'head', type: 'custom', position: {x: 300, y: 500}, data: {label: 'YOLO Head', type: LayerType.DETECT_HEAD, params: {nc: 80}} },
717
+ ],
718
+ edges: [
719
+ { id: '1', source: 'in', target: 'c1' }, { id: '2', source: 'c1', target: 'c2f1' },
720
+ { id: '3', source: 'c2f1', target: 'c2f2' }, { id: '4', source: 'c2f2', target: 'sppf' },
721
+ { id: '5', source: 'sppf', target: 'head' }
722
+ ]
723
+ },
724
+ 'whisper_stt': {
725
+ id: 'whisper_stt',
726
+ name: 'Whisper (STT)',
727
+ description: 'Speech-to-Text Transformer.',
728
+ nodes: [
729
+ { id: 'aud', type: 'custom', position: {x: 100, y: 0}, data: {label: 'Audio', type: LayerType.INPUT, params: {modality: 'Audio'}} },
730
+ { id: 'mel', type: 'custom', position: {x: 100, y: 100}, data: {label: 'MelSpectrogram', type: LayerType.MEL_SPECTROGRAM, params: {n_mels: 80}} },
731
+ { id: 'conv1', type: 'custom', position: {x: 100, y: 200}, data: {label: 'Conv1D', type: LayerType.CONV1D, params: {out_channels: 512, kernel_size: 3}} },
732
+ { id: 'enc', type: 'custom', position: {x: 100, y: 300}, data: {label: 'Transformer Enc', type: LayerType.TRANSFORMER_ENCODER, params: {d_model: 512}} },
733
+
734
+ { id: 'tok', type: 'custom', position: {x: 500, y: 0}, data: {label: 'Text Tokens', type: LayerType.INPUT, params: {modality: 'Text'}} },
735
+ { id: 'emb', type: 'custom', position: {x: 500, y: 100}, data: {label: 'Embedding', type: LayerType.EMBEDDING, params: {}} },
736
+
737
+ { id: 'dec', type: 'custom', position: {x: 300, y: 400}, data: {label: 'Transformer Dec', type: LayerType.TRANSFORMER_DECODER, params: {d_model: 512}} },
738
+ { id: 'out', type: 'custom', position: {x: 300, y: 500}, data: {label: 'Next Token', type: LayerType.LINEAR, params: {}} }
739
+ ],
740
+ edges: [
741
+ { id: '1', source: 'aud', target: 'mel' }, { id: '2', source: 'mel', target: 'conv1' },
742
+ { id: '3', source: 'conv1', target: 'enc' }, { id: '4', source: 'enc', target: 'dec' },
743
+ { id: '5', source: 'tok', target: 'emb' }, { id: '6', source: 'emb', target: 'dec' },
744
+ { id: '7', source: 'dec', target: 'out' }
745
+ ]
746
+ },
747
+ 'tacotron_tts': {
748
+ id: 'tacotron_tts',
749
+ name: 'Voice Cloning (TTS)',
750
+ description: 'Text to Mel Spectrogram with Vocoder.',
751
+ nodes: [
752
+ { id: 'txt', type: 'custom', position: {x: 300, y: 0}, data: {label: 'Text', type: LayerType.INPUT, params: {modality: 'Text'}} },
753
+ { id: 'emb', type: 'custom', position: {x: 300, y: 100}, data: {label: 'Char Embed', type: LayerType.EMBEDDING, params: {embedding_dim: 512}} },
754
+ { id: 'pre', type: 'custom', position: {x: 300, y: 200}, data: {label: 'PreNet (Linear)', type: LayerType.LINEAR, params: {out_features: 256}} },
755
+ { id: 'lstm', type: 'custom', position: {x: 300, y: 300}, data: {label: 'Decoder LSTM', type: LayerType.LSTM, params: {hidden_size: 1024}} },
756
+ { id: 'mel', type: 'custom', position: {x: 300, y: 400}, data: {label: 'Mel Projection', type: LayerType.LINEAR, params: {out_features: 80}} },
757
+ { id: 'voc', type: 'custom', position: {x: 300, y: 500}, data: {label: 'HiFiGAN Vocoder', type: LayerType.VOCODER, params: {type: 'HiFiGAN'}} },
758
+ { id: 'out', type: 'custom', position: {x: 300, y: 600}, data: {label: 'Audio Waveform', type: LayerType.OUTPUT, params: {}} }
759
+ ],
760
+ edges: [
761
+ { id: '1', source: 'txt', target: 'emb' }, { id: '2', source: 'emb', target: 'pre' },
762
+ { id: '3', source: 'pre', target: 'lstm' }, { id: '4', source: 'lstm', target: 'mel' },
763
+ { id: '5', source: 'mel', target: 'voc' }, { id: '6', source: 'voc', target: 'out' }
764
+ ]
765
+ },
766
+ 'nerf_3d': {
767
+ id: 'nerf_3d',
768
+ name: 'NeRF (3D Gen)',
769
+ description: 'Neural Radiance Field MLP.',
770
+ nodes: [
771
+ { id: 'pos', type: 'custom', position: {x: 200, y: 0}, data: {label: 'XYZ Coords', type: LayerType.INPUT, params: {shape: '3'}} },
772
+ { id: 'dir', type: 'custom', position: {x: 400, y: 0}, data: {label: 'View Dir', type: LayerType.INPUT, params: {shape: '3'}} },
773
+ { id: 'pe1', type: 'custom', position: {x: 200, y: 100}, data: {label: 'Pos Enc', type: LayerType.POS_EMBED, params: {}} },
774
+ { id: 'pe2', type: 'custom', position: {x: 400, y: 100}, data: {label: 'Dir Enc', type: LayerType.POS_EMBED, params: {}} },
775
+ { id: 'mlp1', type: 'custom', position: {x: 300, y: 200}, data: {label: 'Density MLP', type: LayerType.NERF_BLOCK, params: {hidden_dim: 256, num_layers: 8}} },
776
+ { id: 'cat', type: 'custom', position: {x: 300, y: 300}, data: {label: 'Concat View', type: LayerType.CONCAT, params: {}} },
777
+ { id: 'mlp2', type: 'custom', position: {x: 300, y: 400}, data: {label: 'Color MLP', type: LayerType.LINEAR, params: {out_features: 128}} },
778
+ { id: 'rgb', type: 'custom', position: {x: 300, y: 500}, data: {label: 'RGB + Sigma', type: LayerType.OUTPUT, params: {}} }
779
+ ],
780
+ edges: [
781
+ { id: '1', source: 'pos', target: 'pe1' }, { id: '2', source: 'dir', target: 'pe2' },
782
+ { id: '3', source: 'pe1', target: 'mlp1' }, { id: '4', source: 'mlp1', target: 'cat' },
783
+ { id: '5', source: 'pe2', target: 'cat' }, { id: '6', source: 'cat', target: 'mlp2' },
784
+ { id: '7', source: 'mlp2', target: 'rgb' }
785
+ ]
786
+ },
787
  'gpt_style': {
788
  id: 'gpt_style',
789
  name: 'LLM (GPT Style)',
 
1004
  { id: '4', source: 'cat', target: 'unet' }, { id: '5', source: 'unet', target: 'out' }
1005
  ]
1006
  }
1007
+ };