Metadata-Version: 2.4
Name: torchinsight
Version: 0.1.0
Summary: Enhanced model analysis tool for PyTorch models
Home-page: https://github.com/Serendipity-zyf/torchinsight
Author: PixelCookie
Author-email: PixelCookie <metazyf@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Serendipity-zyf/torchinsight
Project-URL: Bug Tracker, https://github.com/Serendipity-zyf/torchinsight/issues
Keywords: pytorch,deep-learning,model-analysis,visualization
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=1.7.0
Requires-Dist: colorama>=0.4.4
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# TorchInsight

TorchInsight is an enhanced PyTorch model analysis tool that provides functionality similar to torchinfo but with custom formatting and additional features.

## Features

- Detailed model structure visualization
- Automatic FLOPS calculation with appropriate unit selection (K, M, G)
- Support for input dimension specification without batch dimension
- Support for long dtype specification for specific inputs
- Analysis of various model architectures (CNN, Attention, Recommendation systems, etc.)
- Colorized output for improved readability

## Installation

```bash
pip install torchinsight
```

## Quick Start

```python
import torch
import torch.nn as nn
from torchinsight import analyze_model

# Create a simple model
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 16, kernel_size=3, padding=1)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc = nn.Linear(16 * 16 * 16, 10)
        
    def forward(self, x):
        x = self.pool(torch.relu(self.conv1(x)))
        x = x.view(-1, 16 * 16 * 16)
        x = self.fc(x)
        return x

# Create model instance
model = SimpleModel()

# Analyze model
summary = analyze_model(
    model,
    model_name="SimpleModel",
    input_dims=(3, 32, 32),  # Input dimensions (channels, height, width)
    batch_size=64,  # Batch size
)

# Print analysis results
print(summary)
```

## Advanced Usage

TorchInsight supports multiple input formats and data types:

```python
# Analyze model with multiple inputs
summary = analyze_model(
    model,
    model_name="ComplexModel",
    input_dims=[(13,), (5,)],  # Two inputs with dimensions (13,) and (5,)
    long_indices=[1],  # Second input (index 1) should be torch.long
    batch_size=128,  # Batch size
)
```

For more examples, see the `examples` directory.

## Documentation

For complete documentation, visit:
- [Usage Guide](docs/usage.md)
- [API Reference](docs/api.md)

## Contributing

Contributions are welcome! Feel free to submit Pull Requests or create Issues.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

[中文](README_zh.md)
