HaoLine (好线) - Universal Model Inspector. See what's really inside your models.
Project description
HaoLine (皓线)
Universal Model Inspector — See what's really inside your neural networks.
HaoLine analyzes neural network architectures and generates comprehensive reports with metrics, visualizations, and AI-powered summaries. Works with ONNX, PyTorch, and TensorFlow models.
Complete Beginner Guide
Don't have a model yet? No problem. Follow these steps to analyze your first model in under 5 minutes.
Step 1: Install HaoLine
pip install haoline[llm]
This installs HaoLine with chart generation and AI summary support.
Step 2: Get a Model to Analyze
Option A: Download a pre-trained model from Hugging Face
# Install huggingface_hub if you don't have it
pip install huggingface_hub
# Download a small image classification model (MobileNet, ~14MB)
python -c "from huggingface_hub import hf_hub_download; hf_hub_download('onnx/models', 'validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx', local_dir='.')"
Option B: Use your own model
If you have a .onnx, .pt, .pth, or TensorFlow SavedModel, you can analyze it directly.
Option C: Convert a PyTorch model
# HaoLine can convert PyTorch models on the fly
haoline --from-pytorch your_model.pt --input-shape 1,3,224,224 --out-html report.html
Step 3: Set Up AI Summaries (Optional but Recommended)
To get AI-generated executive summaries, set your OpenAI API key:
# Linux/macOS
export OPENAI_API_KEY="sk-..."
# Windows PowerShell
$env:OPENAI_API_KEY = "sk-..."
# Or create a .env file in your working directory
echo "OPENAI_API_KEY=sk-..." > .env
Get your API key at: https://platform.openai.com/api-keys
Step 4: Generate Your Full Report
haoline mobilenetv2-7.onnx \
--out-html report.html \
--include-graph \
--llm-summary \
--hardware auto
This generates report.html containing:
- Model architecture overview
- Parameter counts and FLOPs analysis
- Memory requirements
- Interactive neural network graph (zoomable, searchable)
- AI-generated executive summary
- Hardware performance estimates for your GPU
Open report.html in your browser to explore your model!
Installation Options
| Command | What You Get |
|---|---|
pip install haoline |
Core analysis + charts |
pip install haoline[llm] |
+ AI-powered summaries |
pip install haoline[full] |
+ PDF export, GPU metrics, runtime profiling |
Common Commands
# Basic analysis (prints to console)
haoline model.onnx
# Generate HTML report with charts
haoline model.onnx --out-html report.html --with-plots
# Full analysis with interactive graph and AI summary
haoline model.onnx --out-html report.html --include-graph --llm-summary
# Specify hardware for performance estimates
haoline model.onnx --hardware rtx4090 --out-html report.html
# Auto-detect your GPU
haoline model.onnx --hardware auto --out-html report.html
# List all available hardware profiles
haoline --list-hardware
# Convert and analyze a PyTorch model
haoline --from-pytorch model.pt --input-shape 1,3,224,224 --out-html report.html
# Convert and analyze a TensorFlow SavedModel
haoline --from-tensorflow ./saved_model_dir --out-html report.html
# Generate JSON for programmatic use
haoline model.onnx --out-json report.json
Compare Model Variants
Compare different quantizations or architectures side-by-side:
haoline compare \
--models resnet_fp32.onnx resnet_fp16.onnx resnet_int8.onnx \
--baseline-precision fp32 \
--out-html comparison.html \
--with-charts
Python API
from haoline import ModelInspector
inspector = ModelInspector()
report = inspector.inspect("model.onnx")
# Access metrics
print(f"Parameters: {report.params.total:,}")
print(f"FLOPs: {report.flops.total:,}")
print(f"Peak Memory: {report.memory.peak_activation_bytes / 1e9:.2f} GB")
# Export reports
report.to_json("report.json")
report.to_markdown("model_card.md")
report.to_html("report.html")
Features
| Feature | Description |
|---|---|
| Parameter Counts | Per-node, per-block, and total parameter analysis |
| FLOP Estimates | Identify compute hotspots in your model |
| Memory Analysis | Peak activation memory and VRAM requirements |
| Risk Signals | Detect problematic architecture patterns |
| Hardware Estimates | GPU utilization predictions for 30+ NVIDIA profiles |
| Runtime Profiling | Actual inference benchmarks with ONNX Runtime |
| Visualizations | Operator histograms, parameter/FLOPs distribution charts |
| Interactive Graph | Zoomable D3.js neural network visualization |
| AI Summaries | GPT-powered executive summaries of your architecture |
| Multiple Formats | Export to HTML, Markdown, PDF, JSON, or CSV |
Supported Model Formats
| Format | Support | Notes |
|---|---|---|
| ONNX (.onnx) | ✅ Full | Native support |
| PyTorch (.pt, .pth) | ✅ Full | Auto-converts to ONNX |
| TensorFlow SavedModel | ✅ Full | Requires tf2onnx |
| Keras (.h5, .keras) | ✅ Full | Requires tf2onnx |
| TensorRT Engine | 🔜 Coming | Planned |
| SafeTensors | 🔜 Coming | Planned |
LLM Providers
HaoLine supports multiple AI providers for generating summaries:
| Provider | Environment Variable | Get API Key |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
platform.openai.com |
| Anthropic | ANTHROPIC_API_KEY |
console.anthropic.com |
| Google Gemini | GOOGLE_API_KEY |
aistudio.google.com |
| xAI Grok | XAI_API_KEY |
console.x.ai |
Where to Find Models
| Source | URL | Notes |
|---|---|---|
| Hugging Face ONNX | huggingface.co/onnx | Pre-converted ONNX models |
| ONNX Model Zoo | github.com/onnx/models | Official ONNX examples |
| Hugging Face Hub | huggingface.co/models | PyTorch/TF models (convert with HaoLine) |
| TorchVision | torchvision.models |
Classic vision models |
| Timm | github.com/huggingface/pytorch-image-models | State-of-the-art vision models |
Security Notice
⚠️ Loading untrusted models is inherently risky.
Like PyTorch's torch.load(), HaoLine uses pickle when loading certain model formats. These can execute arbitrary code if the model file is malicious.
Best practices:
- Only analyze models from trusted sources
- Run in a sandboxed environment (Docker, VM) when analyzing unknown models
- Review model provenance before loading
License
MIT License - See LICENSE for details.
Etymology
HaoLine (皓线) combines:
- 皓 (hào) = "bright, luminous" in Chinese
- Line = the paths through your neural network
"Illuminating the architecture of your models."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haoline-0.2.2.tar.gz.
File metadata
- Download URL: haoline-0.2.2.tar.gz
- Upload date:
- Size: 327.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70579a753ed42471f353964e4ea1aa2073580b141ccfb1234d9b0e3a26765be7
|
|
| MD5 |
c5a30fbce08abb07bbc3bb1fe697b853
|
|
| BLAKE2b-256 |
d16a7608992b35ce457276a060dac2c8c3538ba24f8201937f0ca915799ba5e7
|
File details
Details for the file haoline-0.2.2-py3-none-any.whl.
File metadata
- Download URL: haoline-0.2.2-py3-none-any.whl
- Upload date:
- Size: 211.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a2c03fa1f04e51a765cc4404b2c7fb04035dbdc29dac62418cc778ba8857960
|
|
| MD5 |
5573eb5e679d594d354d726ce3095db9
|
|
| BLAKE2b-256 |
28678b024602d9024d684176fcd193df859922d0be27e9251abc804ec85ce8e5
|