haoline 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. haoline/.streamlit/config.toml +10 -0
  2. haoline/__init__.py +248 -0
  3. haoline/analyzer.py +935 -0
  4. haoline/cli.py +2712 -0
  5. haoline/compare.py +811 -0
  6. haoline/compare_visualizations.py +1564 -0
  7. haoline/edge_analysis.py +525 -0
  8. haoline/eval/__init__.py +131 -0
  9. haoline/eval/adapters.py +844 -0
  10. haoline/eval/cli.py +390 -0
  11. haoline/eval/comparison.py +542 -0
  12. haoline/eval/deployment.py +633 -0
  13. haoline/eval/schemas.py +833 -0
  14. haoline/examples/__init__.py +15 -0
  15. haoline/examples/basic_inspection.py +74 -0
  16. haoline/examples/compare_models.py +117 -0
  17. haoline/examples/hardware_estimation.py +78 -0
  18. haoline/format_adapters.py +1001 -0
  19. haoline/formats/__init__.py +123 -0
  20. haoline/formats/coreml.py +250 -0
  21. haoline/formats/gguf.py +483 -0
  22. haoline/formats/openvino.py +255 -0
  23. haoline/formats/safetensors.py +273 -0
  24. haoline/formats/tflite.py +369 -0
  25. haoline/hardware.py +2307 -0
  26. haoline/hierarchical_graph.py +462 -0
  27. haoline/html_export.py +1573 -0
  28. haoline/layer_summary.py +769 -0
  29. haoline/llm_summarizer.py +465 -0
  30. haoline/op_icons.py +618 -0
  31. haoline/operational_profiling.py +1492 -0
  32. haoline/patterns.py +1116 -0
  33. haoline/pdf_generator.py +265 -0
  34. haoline/privacy.py +250 -0
  35. haoline/pydantic_models.py +241 -0
  36. haoline/report.py +1923 -0
  37. haoline/report_sections.py +539 -0
  38. haoline/risks.py +521 -0
  39. haoline/schema.py +523 -0
  40. haoline/streamlit_app.py +2024 -0
  41. haoline/tests/__init__.py +4 -0
  42. haoline/tests/conftest.py +123 -0
  43. haoline/tests/test_analyzer.py +868 -0
  44. haoline/tests/test_compare_visualizations.py +293 -0
  45. haoline/tests/test_edge_analysis.py +243 -0
  46. haoline/tests/test_eval.py +604 -0
  47. haoline/tests/test_format_adapters.py +460 -0
  48. haoline/tests/test_hardware.py +237 -0
  49. haoline/tests/test_hardware_recommender.py +90 -0
  50. haoline/tests/test_hierarchical_graph.py +326 -0
  51. haoline/tests/test_html_export.py +180 -0
  52. haoline/tests/test_layer_summary.py +428 -0
  53. haoline/tests/test_llm_patterns.py +540 -0
  54. haoline/tests/test_llm_summarizer.py +339 -0
  55. haoline/tests/test_patterns.py +774 -0
  56. haoline/tests/test_pytorch.py +327 -0
  57. haoline/tests/test_report.py +383 -0
  58. haoline/tests/test_risks.py +398 -0
  59. haoline/tests/test_schema.py +417 -0
  60. haoline/tests/test_tensorflow.py +380 -0
  61. haoline/tests/test_visualizations.py +316 -0
  62. haoline/universal_ir.py +856 -0
  63. haoline/visualizations.py +1086 -0
  64. haoline/visualize_yolo.py +44 -0
  65. haoline/web.py +110 -0
  66. haoline-0.3.0.dist-info/METADATA +471 -0
  67. haoline-0.3.0.dist-info/RECORD +70 -0
  68. haoline-0.3.0.dist-info/WHEEL +4 -0
  69. haoline-0.3.0.dist-info/entry_points.txt +5 -0
  70. haoline-0.3.0.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python3
2
+ """Visualize a YOLO model."""
3
+
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ sys.path.insert(0, str(__file__).replace("\\", "/").rsplit("/", 4)[0])
8
+
9
+ from util.haoline.analyzer import ONNXGraphLoader
10
+ from util.haoline.edge_analysis import EdgeAnalyzer
11
+ from util.haoline.hierarchical_graph import HierarchicalGraphBuilder
12
+ from util.haoline.html_export import HTMLExporter
13
+ from util.haoline.patterns import PatternAnalyzer
14
+
15
+ model_path = Path(
16
+ r"C:\Users\marcu\Roomer\room_detection_training\local_training_output\yolo-v8l-200epoch\weights\best.onnx"
17
+ )
18
+
19
+ print(f"Loading {model_path.name}...")
20
+ loader = ONNXGraphLoader()
21
+ _, graph_info = loader.load(model_path)
22
+
23
+ print("Detecting patterns...")
24
+ pattern_analyzer = PatternAnalyzer()
25
+ blocks = pattern_analyzer.group_into_blocks(graph_info)
26
+
27
+ print("Analyzing edges...")
28
+ edge_analyzer = EdgeAnalyzer()
29
+ edge_result = edge_analyzer.analyze(graph_info)
30
+
31
+ print("Building hierarchy...")
32
+ builder = HierarchicalGraphBuilder()
33
+ hier_graph = builder.build(graph_info, blocks, model_path.stem)
34
+
35
+ print("Exporting HTML...")
36
+ exporter = HTMLExporter()
37
+ output_path = exporter.export(
38
+ hier_graph,
39
+ edge_result,
40
+ output_path=model_path.with_suffix(".html"),
41
+ title=model_path.stem,
42
+ )
43
+
44
+ print(f"Done! Open {output_path}")
haoline/web.py ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env python
2
+ # Copyright (c) 2025 HaoLine Contributors
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """
6
+ HaoLine Web UI launcher.
7
+
8
+ Launches the Streamlit web interface for model analysis.
9
+
10
+ Usage:
11
+ haoline-web # Launch the web UI
12
+ haoline-web --port 8080 # Custom port
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import os
19
+ import subprocess
20
+ import sys
21
+ from pathlib import Path
22
+
23
+
24
+ def get_streamlit_app_path() -> Path:
25
+ """Get the path to the bundled streamlit app."""
26
+ # The app is bundled within the package
27
+ return Path(__file__).parent / "streamlit_app.py"
28
+
29
+
30
+ def get_config_dir() -> Path:
31
+ """Get the path to the bundled .streamlit config directory."""
32
+ return Path(__file__).parent / ".streamlit"
33
+
34
+
35
+ def main(argv: list[str] | None = None) -> int:
36
+ """Launch the HaoLine Streamlit web interface."""
37
+ parser = argparse.ArgumentParser(
38
+ prog="haoline-web",
39
+ description="Launch the HaoLine web interface for model analysis.",
40
+ )
41
+ parser.add_argument(
42
+ "--port",
43
+ type=int,
44
+ default=8501,
45
+ help="Port to run the web server on (default: 8501)",
46
+ )
47
+ parser.add_argument(
48
+ "--host",
49
+ type=str,
50
+ default="localhost",
51
+ help="Host to bind to (default: localhost)",
52
+ )
53
+ parser.add_argument(
54
+ "--no-browser",
55
+ action="store_true",
56
+ help="Don't open browser automatically",
57
+ )
58
+
59
+ args = parser.parse_args(argv)
60
+
61
+ # Check if streamlit is installed
62
+ try:
63
+ import streamlit # noqa: F401
64
+ except ImportError:
65
+ print("Error: Streamlit is not installed.")
66
+ print("Install it with: pip install haoline[web]")
67
+ return 1
68
+
69
+ app_path = get_streamlit_app_path()
70
+
71
+ if not app_path.exists():
72
+ print(f"Error: Streamlit app not found at {app_path}")
73
+ print("This may indicate a broken installation. Try reinstalling:")
74
+ print(" pip install --force-reinstall haoline[web]")
75
+ return 1
76
+
77
+ # Build streamlit command
78
+ cmd = [
79
+ sys.executable,
80
+ "-m",
81
+ "streamlit",
82
+ "run",
83
+ str(app_path),
84
+ "--server.port",
85
+ str(args.port),
86
+ "--server.address",
87
+ args.host,
88
+ ]
89
+
90
+ if args.no_browser:
91
+ cmd.extend(["--server.headless", "true"])
92
+
93
+ print(f"Starting HaoLine Web UI at http://{args.host}:{args.port}")
94
+ print("Press Ctrl+C to stop.\n")
95
+
96
+ # Set up environment with config directory for dark theme
97
+ env = os.environ.copy()
98
+ config_dir = get_config_dir()
99
+ if config_dir.exists():
100
+ env["STREAMLIT_CONFIG_DIR"] = str(config_dir)
101
+
102
+ try:
103
+ return subprocess.call(cmd, env=env)
104
+ except KeyboardInterrupt:
105
+ print("\nShutting down...")
106
+ return 0
107
+
108
+
109
+ if __name__ == "__main__":
110
+ sys.exit(main())
@@ -0,0 +1,471 @@
1
+ Metadata-Version: 2.4
2
+ Name: haoline
3
+ Version: 0.3.0
4
+ Summary: HaoLine (皓线) - Universal Model Inspector. See what's really inside your models.
5
+ Project-URL: Homepage, https://github.com/mdayku/HaoLine
6
+ Project-URL: Documentation, https://github.com/mdayku/HaoLine#readme
7
+ Project-URL: Repository, https://github.com/mdayku/HaoLine
8
+ Project-URL: Issues, https://github.com/mdayku/HaoLine/issues
9
+ Project-URL: Changelog, https://github.com/mdayku/HaoLine/blob/main/CHANGELOG.md
10
+ Author-email: Marcus Day <marcusday3586@gmail.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: deep-learning,flops,machine-learning,memory,model-analysis,model-inspector,neural-network,onnx,parameters,profiling,pytorch,tensorflow,tensorrt
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Environment :: Web Environment
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: Science/Research
19
+ Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: matplotlib>=3.5.0
30
+ Requires-Dist: numpy>=1.20.0
31
+ Requires-Dist: onnx>=1.14.0
32
+ Requires-Dist: pydantic>=2.0.0
33
+ Provides-Extra: coreml
34
+ Requires-Dist: coremltools>=7.0; extra == 'coreml'
35
+ Provides-Extra: dev
36
+ Requires-Dist: black>=23.0.0; extra == 'dev'
37
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
38
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
39
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
41
+ Provides-Extra: formats
42
+ Requires-Dist: safetensors>=0.4.0; extra == 'formats'
43
+ Requires-Dist: tflite-runtime>=2.14.0; extra == 'formats'
44
+ Provides-Extra: full
45
+ Requires-Dist: anthropic>=0.20.0; extra == 'full'
46
+ Requires-Dist: google-generativeai>=0.3.0; extra == 'full'
47
+ Requires-Dist: matplotlib>=3.5.0; extra == 'full'
48
+ Requires-Dist: nvidia-ml-py>=12.0.0; extra == 'full'
49
+ Requires-Dist: onnxruntime>=1.16.0; extra == 'full'
50
+ Requires-Dist: openai>=1.0.0; extra == 'full'
51
+ Requires-Dist: playwright>=1.40.0; extra == 'full'
52
+ Requires-Dist: python-dotenv>=1.0.0; extra == 'full'
53
+ Requires-Dist: safetensors>=0.4.0; extra == 'full'
54
+ Requires-Dist: streamlit>=1.28.0; extra == 'full'
55
+ Requires-Dist: tflite-runtime>=2.14.0; extra == 'full'
56
+ Provides-Extra: gpu
57
+ Requires-Dist: nvidia-ml-py>=12.0.0; extra == 'gpu'
58
+ Provides-Extra: llm
59
+ Requires-Dist: anthropic>=0.20.0; extra == 'llm'
60
+ Requires-Dist: google-generativeai>=0.3.0; extra == 'llm'
61
+ Requires-Dist: openai>=1.0.0; extra == 'llm'
62
+ Requires-Dist: python-dotenv>=1.0.0; extra == 'llm'
63
+ Provides-Extra: openvino
64
+ Requires-Dist: openvino>=2024.0.0; extra == 'openvino'
65
+ Provides-Extra: pdf
66
+ Requires-Dist: playwright>=1.40.0; extra == 'pdf'
67
+ Provides-Extra: runtime
68
+ Requires-Dist: onnxruntime>=1.16.0; extra == 'runtime'
69
+ Provides-Extra: safetensors
70
+ Requires-Dist: safetensors>=0.4.0; extra == 'safetensors'
71
+ Provides-Extra: tflite
72
+ Requires-Dist: tflite-runtime>=2.14.0; extra == 'tflite'
73
+ Provides-Extra: viz
74
+ Requires-Dist: matplotlib>=3.5.0; extra == 'viz'
75
+ Provides-Extra: web
76
+ Requires-Dist: streamlit>=1.28.0; extra == 'web'
77
+ Description-Content-Type: text/markdown
78
+
79
+ # HaoLine (皓线)
80
+
81
+ **Universal Model Inspector — See what's really inside your neural networks.**
82
+
83
+ [![PyPI version](https://badge.fury.io/py/haoline.svg)](https://badge.fury.io/py/haoline)
84
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
85
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
86
+
87
+ HaoLine analyzes neural network architectures and generates comprehensive reports with metrics, visualizations, and AI-powered summaries. Works with ONNX, PyTorch, and TensorFlow models.
88
+
89
+ ---
90
+
91
+ ## Complete Beginner Guide
92
+
93
+ **Don't have a model yet?** No problem. Follow these steps to analyze your first model in under 5 minutes.
94
+
95
+ ### Step 1: Install HaoLine
96
+
97
+ ```bash
98
+ pip install haoline[llm]
99
+ ```
100
+
101
+ This installs HaoLine with chart generation and AI summary support.
102
+
103
+ ### Step 2: Get a Model to Analyze
104
+
105
+ **Option A: Download a pre-trained model from Hugging Face**
106
+
107
+ ```bash
108
+ # Install huggingface_hub if you don't have it
109
+ pip install huggingface_hub
110
+
111
+ # Download a small image classification model (MobileNet, ~14MB)
112
+ python -c "from huggingface_hub import hf_hub_download; hf_hub_download('onnx/models', 'validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx', local_dir='.')"
113
+ ```
114
+
115
+ **Option B: Use your own model**
116
+
117
+ If you have a `.onnx`, `.pt`, `.pth`, or TensorFlow SavedModel, you can analyze it directly.
118
+
119
+ **Option C: Convert a PyTorch model**
120
+
121
+ ```bash
122
+ # HaoLine can convert PyTorch models on the fly
123
+ haoline --from-pytorch your_model.pt --input-shape 1,3,224,224 --out-html report.html
124
+ ```
125
+
126
+ ### Step 3: Set Up AI Summaries (Optional but Recommended)
127
+
128
+ To get AI-generated executive summaries, set your OpenAI API key:
129
+
130
+ ```bash
131
+ # Linux/macOS
132
+ export OPENAI_API_KEY="sk-..."
133
+
134
+ # Windows PowerShell
135
+ $env:OPENAI_API_KEY = "sk-..."
136
+
137
+ # Or create a .env file in your working directory
138
+ echo "OPENAI_API_KEY=sk-..." > .env
139
+ ```
140
+
141
+ Get your API key at: https://platform.openai.com/api-keys
142
+
143
+ ### Step 4: Generate Your Full Report
144
+
145
+ ```bash
146
+ haoline mobilenetv2-7.onnx \
147
+ --out-html report.html \
148
+ --include-graph \
149
+ --llm-summary \
150
+ --hardware auto
151
+ ```
152
+
153
+ This generates `report.html` containing:
154
+ - Model architecture overview
155
+ - Parameter counts and FLOPs analysis
156
+ - Memory requirements
157
+ - Interactive neural network graph (zoomable, searchable)
158
+ - AI-generated executive summary
159
+ - Hardware performance estimates for your GPU
160
+
161
+ **Open `report.html` in your browser to explore your model!**
162
+
163
+ ---
164
+
165
+ ## Web Interface
166
+
167
+ **Try it now:** [huggingface.co/spaces/mdayku/haoline](https://huggingface.co/spaces/mdayku/haoline) — no installation required!
168
+
169
+ Or run locally with a single command:
170
+
171
+ ```bash
172
+ pip install haoline[web]
173
+ haoline-web
174
+ ```
175
+
176
+ This opens an interactive dashboard at `http://localhost:8501` with:
177
+
178
+ - Drag-and-drop model upload (ONNX, PyTorch)
179
+ - Hardware selection with 50+ GPU profiles (searchable)
180
+ - **NEW:** Batch size and GPU count controls
181
+ - **NEW:** System Requirements (Steam-style min/rec/optimal)
182
+ - **NEW:** Deployment Cost Calculator (monthly cloud cost estimates)
183
+ - **NEW:** Cloud instance selector (T4, A10G, A100, H100, Jetson)
184
+ - Full interactive D3.js neural network graph
185
+ - Model comparison mode (side-by-side analysis)
186
+ - **NEW:** Per-layer timing breakdown (when benchmarked)
187
+ - **NEW:** Memory usage overview chart
188
+ - **NEW:** Run Benchmark button (actual ONNX Runtime measurements)
189
+ - **NEW:** Privacy controls (redact layer names, summary-only mode)
190
+ - AI-powered summaries (bring your own API key)
191
+ - Export to PDF, HTML, JSON, Markdown, **Universal IR**, **DOT graph**
192
+
193
+ > **Want to deploy your own?** See [DEPLOYMENT.md](DEPLOYMENT.md) for HuggingFace Spaces, Docker, and self-hosted options.
194
+
195
+ ---
196
+
197
+ ## Installation Options
198
+
199
+ | Command | What You Get |
200
+ |---------|--------------|
201
+ | `pip install haoline` | Core analysis + charts |
202
+ | `pip install haoline[llm]` | + AI-powered summaries |
203
+ | `pip install haoline[full]` | + PDF export, GPU metrics, runtime profiling |
204
+
205
+ ---
206
+
207
+ ## Common Commands
208
+
209
+ ```bash
210
+ # Basic analysis (prints to console)
211
+ haoline model.onnx
212
+
213
+ # Generate HTML report with charts
214
+ haoline model.onnx --out-html report.html --with-plots
215
+
216
+ # Full analysis with interactive graph and AI summary
217
+ haoline model.onnx --out-html report.html --include-graph --llm-summary
218
+
219
+ # Specify hardware for performance estimates
220
+ haoline model.onnx --hardware rtx4090 --out-html report.html
221
+
222
+ # Auto-detect your GPU
223
+ haoline model.onnx --hardware auto --out-html report.html
224
+
225
+ # List all available hardware profiles
226
+ haoline --list-hardware
227
+
228
+ # Convert and analyze a PyTorch model
229
+ haoline --from-pytorch model.pt --input-shape 1,3,224,224 --out-html report.html
230
+
231
+ # Convert and analyze a TensorFlow SavedModel
232
+ haoline --from-tensorflow ./saved_model_dir --out-html report.html
233
+
234
+ # Generate JSON for programmatic use
235
+ haoline model.onnx --out-json report.json
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Compare Model Variants
241
+
242
+ Compare different quantizations or architectures side-by-side:
243
+
244
+ ```bash
245
+ haoline-compare \
246
+ --models resnet_fp32.onnx resnet_fp16.onnx resnet_int8.onnx \
247
+ --eval-metrics eval_fp32.json eval_fp16.json eval_int8.json \
248
+ --baseline-precision fp32 \
249
+ --out-html comparison.html \
250
+ --with-charts
251
+ ```
252
+
253
+ Or use the web UI's comparison mode for an interactive experience.
254
+
255
+ ---
256
+
257
+ ## CLI Reference
258
+
259
+ ### Output Options
260
+
261
+ | Flag | Description |
262
+ |------|-------------|
263
+ | `--out-json PATH` | Write JSON report |
264
+ | `--out-md PATH` | Write Markdown model card |
265
+ | `--out-html PATH` | Write HTML report (single shareable file) |
266
+ | `--out-pdf PATH` | Write PDF report (requires playwright) |
267
+ | `--html-graph PATH` | Write standalone interactive graph HTML |
268
+ | `--layer-csv PATH` | Write per-layer metrics CSV |
269
+
270
+ ### Report Options
271
+
272
+ | Flag | Description |
273
+ |------|-------------|
274
+ | `--include-graph` | Embed interactive D3.js graph in HTML report |
275
+ | `--include-layer-table` | Include sortable per-layer table in HTML |
276
+ | `--with-plots` | Generate matplotlib visualization charts |
277
+ | `--assets-dir PATH` | Directory for chart PNG files |
278
+
279
+ ### Hardware Options
280
+
281
+ | Flag | Description |
282
+ |------|-------------|
283
+ | `--hardware PROFILE` | GPU profile (`auto`, `rtx4090`, `a100`, `h100`, etc.) |
284
+ | `--list-hardware` | Show all 50+ available GPU profiles |
285
+ | `--precision {fp32,fp16,bf16,int8}` | Precision for estimates |
286
+ | `--batch-size N` | Batch size for estimates |
287
+ | `--gpu-count N` | Multi-GPU scaling (2, 4, 8) |
288
+ | `--cloud INSTANCE` | Cloud instance (e.g., `aws-p4d-24xlarge`) |
289
+ | `--list-cloud` | Show available cloud instances |
290
+ | `--system-requirements` | Generate Steam-style min/recommended specs |
291
+ | `--sweep-batch-sizes` | Find optimal batch size |
292
+ | `--sweep-resolutions` | Analyze resolution scaling |
293
+
294
+ ### LLM Options
295
+
296
+ | Flag | Description |
297
+ |------|-------------|
298
+ | `--llm-summary` | Generate AI-powered executive summary |
299
+ | `--llm-model MODEL` | Model to use (default: `gpt-4o-mini`) |
300
+
301
+ ### Conversion Options
302
+
303
+ | Flag | Description |
304
+ |------|-------------|
305
+ | `--from-pytorch PATH` | Convert PyTorch model to ONNX |
306
+ | `--from-tensorflow PATH` | Convert TensorFlow SavedModel |
307
+ | `--from-keras PATH` | Convert Keras .h5/.keras model |
308
+ | `--from-jax PATH` | Convert JAX/Flax model |
309
+ | `--input-shape SHAPE` | Input shape for conversion (e.g., `1,3,224,224`) |
310
+ | `--keep-onnx PATH` | Save converted ONNX to path |
311
+
312
+ ### Privacy Options
313
+
314
+ | Flag | Description |
315
+ |------|-------------|
316
+ | `--redact-names` | Anonymize layer names for IP protection |
317
+ | `--summary-only` | Show only aggregate statistics |
318
+ | `--offline` | Disable all network requests |
319
+
320
+ ### Universal IR Export
321
+
322
+ | Flag | Description |
323
+ |------|-------------|
324
+ | `--export-ir PATH` | Export format-agnostic graph as JSON |
325
+ | `--export-graph PATH` | Export graph as DOT or PNG (Graphviz) |
326
+ | `--list-conversions` | Show all supported format conversions |
327
+
328
+ ### Other Options
329
+
330
+ | Flag | Description |
331
+ |------|-------------|
332
+ | `--quiet` | Suppress console output |
333
+ | `--progress` | Show progress for large models |
334
+ | `--log-level {debug,info,warning,error}` | Logging verbosity |
335
+
336
+ ---
337
+
338
+ ## Python API
339
+
340
+ ```python
341
+ from haoline import ModelInspector
342
+
343
+ inspector = ModelInspector()
344
+ report = inspector.inspect("model.onnx")
345
+
346
+ # Access metrics
347
+ print(f"Parameters: {report.param_counts.total:,}")
348
+ print(f"FLOPs: {report.flop_counts.total:,}")
349
+ print(f"Peak Memory: {report.memory_estimates.peak_activation_bytes / 1e9:.2f} GB")
350
+
351
+ # Export reports
352
+ report.to_json("report.json")
353
+ report.to_markdown("model_card.md")
354
+ report.to_html("report.html")
355
+ ```
356
+
357
+ ---
358
+
359
+ ## Features
360
+
361
+ | Feature | Description |
362
+ |---------|-------------|
363
+ | **Parameter Counts** | Per-node, per-block, and total parameter analysis |
364
+ | **FLOP Estimates** | Identify compute hotspots in your model |
365
+ | **Memory Analysis** | Peak activation memory and VRAM requirements |
366
+ | **Risk Signals** | Detect problematic architecture patterns |
367
+ | **Hardware Estimates** | GPU utilization predictions for 30+ NVIDIA profiles |
368
+ | **Runtime Profiling** | Actual inference benchmarks with ONNX Runtime |
369
+ | **Visualizations** | Operator histograms, parameter/FLOPs distribution charts |
370
+ | **Interactive Graph** | Zoomable D3.js neural network visualization |
371
+ | **AI Summaries** | GPT-powered executive summaries of your architecture |
372
+ | **Multiple Formats** | Export to HTML, Markdown, PDF, JSON, or CSV |
373
+ | **Universal IR** | Format-agnostic intermediate representation for cross-format analysis |
374
+
375
+ ---
376
+
377
+ ## Universal IR (Internal Representation)
378
+
379
+ HaoLine uses a Universal IR to represent models in a format-agnostic way, enabling:
380
+
381
+ - **Cross-format comparison**: Compare PyTorch vs ONNX vs TensorFlow architectures
382
+ - **Structural analysis**: Check if two models are architecturally identical
383
+ - **Graph visualization**: Export to Graphviz DOT or PNG
384
+
385
+ ```bash
386
+ # Export model as Universal IR (JSON)
387
+ haoline model.onnx --export-ir model_ir.json
388
+
389
+ # Export graph visualization
390
+ haoline model.onnx --export-graph graph.dot
391
+ haoline model.onnx --export-graph graph.png --graph-max-nodes 200
392
+
393
+ # List available format conversions
394
+ haoline --list-conversions
395
+ ```
396
+
397
+ The Universal IR includes:
398
+ - **UniversalGraph**: Container for nodes, tensors, and metadata
399
+ - **UniversalNode**: Format-agnostic operation representation
400
+ - **UniversalTensor**: Weight, input, output, and activation metadata
401
+
402
+ ---
403
+
404
+ ## Supported Model Formats
405
+
406
+ | Format | Support | Notes |
407
+ |--------|---------|-------|
408
+ | ONNX (.onnx) | ✅ Full | Native support |
409
+ | PyTorch (.pt, .pth) | ✅ Full | Auto-converts to ONNX |
410
+ | TensorFlow SavedModel | ✅ Full | Requires tf2onnx |
411
+ | Keras (.h5, .keras) | ✅ Full | Requires tf2onnx |
412
+ | GGUF (.gguf) | ✅ Read | llama.cpp LLMs (`pip install haoline`) |
413
+ | SafeTensors (.safetensors) | ✅ Read | HuggingFace weights (`pip install haoline[formats]`) |
414
+ | TFLite (.tflite) | ✅ Read | Mobile/edge (`pip install haoline[formats]`) |
415
+ | CoreML (.mlmodel, .mlpackage) | ✅ Read | Apple devices (`pip install haoline[coreml]`) |
416
+ | OpenVINO (.xml) | ✅ Read | Intel inference (`pip install haoline[openvino]`) |
417
+ | TensorRT Engine | 🔜 Coming | NVIDIA optimized engines |
418
+
419
+ ---
420
+
421
+ ## LLM Providers
422
+
423
+ HaoLine supports multiple AI providers for generating summaries:
424
+
425
+ | Provider | Environment Variable | Get API Key |
426
+ |----------|---------------------|-------------|
427
+ | OpenAI | `OPENAI_API_KEY` | [platform.openai.com](https://platform.openai.com/api-keys) |
428
+ | Anthropic | `ANTHROPIC_API_KEY` | [console.anthropic.com](https://console.anthropic.com/) |
429
+ | Google Gemini | `GOOGLE_API_KEY` | [aistudio.google.com](https://aistudio.google.com/app/apikey) |
430
+ | xAI Grok | `XAI_API_KEY` | [console.x.ai](https://console.x.ai/) |
431
+
432
+ ---
433
+
434
+ ## Where to Find Models
435
+
436
+ | Source | URL | Notes |
437
+ |--------|-----|-------|
438
+ | Hugging Face ONNX | [huggingface.co/onnx](https://huggingface.co/onnx) | Pre-converted ONNX models |
439
+ | ONNX Model Zoo | [github.com/onnx/models](https://github.com/onnx/models) | Official ONNX examples |
440
+ | Hugging Face Hub | [huggingface.co/models](https://huggingface.co/models) | PyTorch/TF models (convert with HaoLine) |
441
+ | TorchVision | `torchvision.models` | Classic vision models |
442
+ | Timm | [github.com/huggingface/pytorch-image-models](https://github.com/huggingface/pytorch-image-models) | State-of-the-art vision models |
443
+
444
+ ---
445
+
446
+ ## Security Notice
447
+
448
+ ⚠️ **Loading untrusted models is inherently risky.**
449
+
450
+ Like PyTorch's `torch.load()`, HaoLine uses `pickle` when loading certain model formats. These can execute arbitrary code if the model file is malicious.
451
+
452
+ **Best practices:**
453
+ - Only analyze models from trusted sources
454
+ - Run in a sandboxed environment (Docker, VM) when analyzing unknown models
455
+ - Review model provenance before loading
456
+
457
+ ---
458
+
459
+ ## License
460
+
461
+ MIT License - See [LICENSE](LICENSE) for details.
462
+
463
+ ---
464
+
465
+ ## Etymology
466
+
467
+ **HaoLine** (皓线) combines:
468
+ - 皓 (hào) = "bright, luminous" in Chinese
469
+ - Line = the paths through your neural network
470
+
471
+ *"Illuminating the architecture of your models."*
@@ -0,0 +1,70 @@
1
+ haoline/__init__.py,sha256=X5MQk2oUDc9UJcHCyomAC-6yEvFH7pG5ZnNXDMbGMB4,6645
2
+ haoline/analyzer.py,sha256=YTttwpqjA9yELhj-ziVqhipUEx5d5xDbqu7654y5Hwk,37024
3
+ haoline/cli.py,sha256=xqLna6YY2L-eAtQVqn4xm9apCikxGsWjVTFCXYjVm60,100749
4
+ haoline/compare.py,sha256=2epr4ZSK0PlQYWzSbvHmiqBSgjkFBfIxQGSiEe1jXQg,29122
5
+ haoline/compare_visualizations.py,sha256=vLiSMr29noV81WS5K_wDHe4axahW5w-yROFNHqtecfI,53006
6
+ haoline/edge_analysis.py,sha256=Y3o5v85G3AZyCQyuVmrtPHCK63tiKHPDs8OVmbZi-0A,18010
7
+ haoline/format_adapters.py,sha256=BjLlDI3QqjS0q3niVhm7jocpzDtqW5FpiGBJ7883d78,33757
8
+ haoline/hardware.py,sha256=XS8NykPId15tI_1yilS3Iqyd_bERx-UEbvvqaUFnZIM,77521
9
+ haoline/hierarchical_graph.py,sha256=PjH687ApgQyXLT21FapvZoLsjOwTFBMXTiJxknOyESY,15851
10
+ haoline/html_export.py,sha256=NAltKGDcRHVaNtV3ydp_FWo5WwTEKkUGnrVYBhIegME,60766
11
+ haoline/layer_summary.py,sha256=enumGcgmkNM8qyH4hY2kjZivZ7rAZ8Qh6yWvLDiAEtU,26416
12
+ haoline/llm_summarizer.py,sha256=BK9reMlh2GNAzabKEoPhfBeXsPCfUgn5885JzQMgFGA,18056
13
+ haoline/op_icons.py,sha256=w41dXtoTjqNLKbGWMpP1D4d9r4tYU_C7HllChq0ufhQ,19578
14
+ haoline/operational_profiling.py,sha256=7FfggwT8Uy3LyOmOTuXDxUFjIAKQmKYKVL0LYQCiQU4,54921
15
+ haoline/patterns.py,sha256=QHav0dL5O4kCZ4agBQhGXPJ2PYqAAUsduONBhz3JzbY,45659
16
+ haoline/pdf_generator.py,sha256=Kcnk3VTu-C-Lwi_LsZ3OM6Sne5w_ze-14KQWm-uXowQ,9470
17
+ haoline/privacy.py,sha256=qtWAZCUpB5l3-2mOWEnViY5gwxcK6DGnDosKpQqF5Lg,8458
18
+ haoline/pydantic_models.py,sha256=t6hKMTbw1wOceHEobVR6rME3-yRamzCmUtxOVhsR1WU,9396
19
+ haoline/report.py,sha256=29AsHoKoiemlZpIbXjue2Mwa4sZeSTonwqabwyWnyqM,76212
20
+ haoline/report_sections.py,sha256=hIu51QGGTvIU7ZEYTL-pzCTr0zE8TPuldnIcPXVZWOg,17494
21
+ haoline/risks.py,sha256=4eL-xwJlF13ndUj9R-lYoojijFf5J7UdGhPWOrmScpw,19873
22
+ haoline/schema.py,sha256=9aVEXkbOVqZGMZ5OsOCV0akhKViwYBpsM_lNLhJoklk,20353
23
+ haoline/streamlit_app.py,sha256=_QyfA3ORh2x36EZq_C7jGMM_5qYECGAsLeIdvH7gBn4,80602
24
+ haoline/universal_ir.py,sha256=WBKxfonhL7-QgHAE0Ki6G-7UmyUC2rj6YlZN0ixejtU,30717
25
+ haoline/visualizations.py,sha256=83V0XwY1cKNWL_PJxtmitjWjKzh34x1devSA2QiadE0,35776
26
+ haoline/visualize_yolo.py,sha256=l0k1wKy0dgeoGiYoM2efunkzd79qJeMVFRVXxYoviTg,1316
27
+ haoline/web.py,sha256=sYYU0ObvRfC0X7XDsnTltLNIByTZB5l3JiF3by1sMe0,2921
28
+ haoline/.streamlit/config.toml,sha256=OoeP2GLvcQg6-ouZYF5RKDXxxDCibzgAJY-vgehMfoQ,175
29
+ haoline/eval/__init__.py,sha256=Id1mi4PDhZeuwgwhw0ObaUk1oxL8UFZlK5GnXhjXm7M,3271
30
+ haoline/eval/adapters.py,sha256=DHazME6YerCruZp4bTbmx-Dyog5PYpS4cX220BG2OQU,28138
31
+ haoline/eval/cli.py,sha256=ihf1UzLt2JR0rYmTcac1J5zaBtG7b-cpTCy3qkNyW2M,12466
32
+ haoline/eval/comparison.py,sha256=cgkpgiNY8wVeWsdy-XWjlenoGZmxXuwCGWXCcV6L-lY,17679
33
+ haoline/eval/deployment.py,sha256=G2_4SeNEiGrr5zxfwZi20SUQWqP1ZER5ty3Tkh2VvHg,21458
34
+ haoline/eval/schemas.py,sha256=ZxMGDIOjzv7uFECmqXc6dF6_srWXj8aFyb-h43eUPog,26736
35
+ haoline/examples/__init__.py,sha256=6N49SoBePYOid8XAgBxBDsA9-GkJhG_pPK1x36Y_1j8,492
36
+ haoline/examples/basic_inspection.py,sha256=9jr5QhIYCrllZDWmzmi3FW0jG_fM3mciy1PVuI-E_jQ,2149
37
+ haoline/examples/compare_models.py,sha256=ATxne-kFmPBYTR3eSs2IrsBx1EoCVBPAfHuMKhgB-5Q,3603
38
+ haoline/examples/hardware_estimation.py,sha256=UQ0jIJyQAV0Hq74BPLgiJvfmeC1hjmNGEtH1e6vvkVw,2308
39
+ haoline/formats/__init__.py,sha256=fSR7jQnmF0NS7Y6P_Pj5pxpifdMU1t8_Vut8oEJ8goM,2948
40
+ haoline/formats/coreml.py,sha256=fCU_iFzpuXJ7uju-T-l-BRUfgVEMWQsslVqM7syFMIc,7961
41
+ haoline/formats/gguf.py,sha256=EL1SqxJiXaY3pwwlE28R16W8GfWZnqDjbCfi4id3BSU,15343
42
+ haoline/formats/openvino.py,sha256=mApzb4Aj3a_jX2VvSLlfMvcK7z7vwFphtiJXp4iPWpg,7878
43
+ haoline/formats/safetensors.py,sha256=nO5MUhXTwPyeluAa1W4jDLoCaqC2KSi7DxBqdbIjtYY,7764
44
+ haoline/formats/tflite.py,sha256=DxdmnDLO09-khbt85zYr2XD0buENVSX9HlfQ_9aMerE,10614
45
+ haoline/tests/__init__.py,sha256=HSbYxxTpeXSudDMh-xkVThIr2JyyHqP4BKXevFsqKLw,110
46
+ haoline/tests/conftest.py,sha256=IPqruuvPOe_dzQSwSDLi1yinHTGnGK4afNdcX6P_DlI,3838
47
+ haoline/tests/test_analyzer.py,sha256=3qV_dxMRFZ0EiAgN-0KnKEejfVdvnaUHybFDuDbREkY,28847
48
+ haoline/tests/test_compare_visualizations.py,sha256=iT3n-EY0NlC7lxy7SVYa9luB4v9weE6uPJ8LHTuuvLo,11120
49
+ haoline/tests/test_edge_analysis.py,sha256=bMTSm3nV5vEmBF4r8a7gfdEJFbOMTwXwJP25lNptuk0,7918
50
+ haoline/tests/test_eval.py,sha256=JzdnEd_z5drAB4LpeOFZI5tBXgKUsBtYvh22U7qXOLA,20393
51
+ haoline/tests/test_format_adapters.py,sha256=biT0Rcwevf3V8harsohGQYKhN063Jpv_ccjkTpy1zFg,17082
52
+ haoline/tests/test_hardware.py,sha256=KcjT_Vul5o7MPYO-ftqlYNdUXcPwNnPcLh0lBj5lj3A,8151
53
+ haoline/tests/test_hardware_recommender.py,sha256=_uJ3VBuDA6VaWL8Yqzjqb7BP2ngJjHPg1Fs-NOqynok,3101
54
+ haoline/tests/test_hierarchical_graph.py,sha256=z3L2F9UyBybuq096ZoyDCTq3Sayql5MBkbhQJL90kWc,10038
55
+ haoline/tests/test_html_export.py,sha256=MdUz_6bVqrd8sseDLrDd8SVnq6ZxNnOhFUzhFy6RaOY,5713
56
+ haoline/tests/test_layer_summary.py,sha256=L3nQUYav-5n1xqUwjIdesWTwrPzu44SGYMgx4ZBA9Y8,14817
57
+ haoline/tests/test_llm_patterns.py,sha256=tqGtjTIj59Nj7HO9S3GPNDKTmBtLvnxkK84ZkAkDQbQ,18619
58
+ haoline/tests/test_llm_summarizer.py,sha256=QT7tEIKQpSpe_SZ2UANOLKnIRjYvDQRgxUc5Kk6qsXA,10904
59
+ haoline/tests/test_patterns.py,sha256=i6I1z_NTApRIlkiIl15chXNUoF-w8zJ3yCQwMM1SGJE,26286
60
+ haoline/tests/test_pytorch.py,sha256=BW_SjFfpKpSXsSqk-TDS77Kq_XcpTTwjPSFmQN5-W9s,10981
61
+ haoline/tests/test_report.py,sha256=DW7pyixAQRYZKZXnh1ehGDAN772N9-GrjSp_AK40Rdw,13093
62
+ haoline/tests/test_risks.py,sha256=w3YfHQHDG3jn2pw39tAkcY8qXOFnKwrv6zLpUc3_Ow4,14603
63
+ haoline/tests/test_schema.py,sha256=91BSUhPOKOb7z89BOMvjeuIAWTFFGP-bzSc2r2jHiCs,14448
64
+ haoline/tests/test_tensorflow.py,sha256=K9pVd63k835zyG3gH2a6VXzHGNgrvDo1qRt3wHT3KOA,12062
65
+ haoline/tests/test_visualizations.py,sha256=k4RXG_T_VW8kL-KF7_dhossEDu5CxvShAjSmI7nMD8I,10570
66
+ haoline-0.3.0.dist-info/METADATA,sha256=lJ5h_N1r6iBK5ERftg10PXhaUZgWDrRWUG22XWCFekU,16347
67
+ haoline-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
68
+ haoline-0.3.0.dist-info/entry_points.txt,sha256=L4shBI6eAO14k2VbV2Zx2Sw7mfT3_bw-xRPMCINXKdk,166
69
+ haoline-0.3.0.dist-info/licenses/LICENSE,sha256=_ktRHwuyG2LBwOGwXYIv6IZ6Av2FyrptFefD9RXGNM0,1090
70
+ haoline-0.3.0.dist-info/RECORD,,