divitmittal's picture
docs: add agent and crush guidelines
2f467de
|
raw
history blame
1.79 kB
# CRUSH Guidelines for HF Demo
## Build/Run Commands
- **Setup**: `pip install -r requirements.txt`
- **Run Demo**: `python app.py`
- **Run Main**: `python main.py`
## Lint/Test Commands
- **Lint**: `flake8 .` or `ruff check .`
- **Format**: `black .` or `ruff format .`
- **Type Check**: `mypy --ignore-missing-imports .`
- **Single File Test**: `python -m pytest tests/test_file.py::test_function_name -v`
## Code Style Guidelines
- **Language**: Python 3.12+, PyTorch-based
- **Imports**: Standard library, third-party (torch, torchvision, gradio), then local
- **Formatting**: Black-compatible, 88 char line limit
- **Naming**: snake_case for functions/variables, PascalCase for classes
- **Types**: Use type hints where possible (`torch.Tensor`, etc.)
- **Docstrings**: Not required for this demo app
- **Error Handling**: Use try/except for file I/O and model operations
## Key Architecture Components (HF Demo)
- **FocalCrossViTHybrid**: Main hybrid model combining Focal Transformer + CrossViT
- **FocalModulation**: Adaptive spatial attention with multi-scale focal windows
- **CrossAttention**: Cross-attention mechanism between near/far focus images
- **Gradio Interface**: Web UI for image fusion demo
## Important Conventions
- Models loaded from Hugging Face automatically
- Use `torch.device('cuda' if torch.cuda.is_available() else 'cpu')`
- Image size: 224x224 for model compatibility
- Follow Gradio patterns for UI components
- Include proper error messages for missing inputs
## File Structure
- **app.py**: Main Gradio application with model definition and UI
- **main.py**: Simple entry point
- **requirements.txt**: Dependencies for HF Spaces
## Test Commands
- No formal tests in this directory
- Test locally by running `python app.py` and uploading images