Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 0 additions & 116 deletions .github/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
run: twine check dist/*

- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist-packages
path: dist/
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/pre-commit.yml

This file was deleted.

162 changes: 45 additions & 117 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,142 +1,70 @@
# Pre-commit hooks for CABiNet project
# Note: pre-commit will ignore anything that is already ignored by Git.
# Pre-commit hooks configuration
# See https://pre-commit.com for more information

default_language_version:
python: python3.10
python: python3

repos:
# Python code formatting
- repo: https://github.com/psf/black
rev: 25.1.0
# ---------- BASIC SANITY ----------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: black
language_version: python3
args: [--line-length=100]
exclude: ^(legacy/|.*\.ipynb)
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-added-large-files
args: [--maxkb=5000]
- id: check-ast
- id: debug-statements
- id: check-merge-conflict
- id: detect-private-key

# Import sorting
- repo: https://github.com/pycqa/isort
rev: 5.13.2
# ---------- PYTHON FORMAT ----------
- repo: https://github.com/psf/black
rev: 25.12.0
hooks:
- id: isort
language_version: python3
args: [--profile=black, --line-length=100]
exclude: ^(legacy/|.*\.ipynb)
- id: black
args: [--line-length=88]

# Linting
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
# ---------- PYTHON LINT (NO FIX) ----------
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
hooks:
- id: flake8
language_version: python3
additional_dependencies: [
"flake8-docstrings",
"flake8-bugbear",
"flake8-comprehensions",
"pep8-naming",
]
args: [--max-line-length=100, --extend-ignore=E203,W503]
exclude: ^(legacy/|tests/|.*\.ipynb)
- id: ruff
args: [--fix]
types_or: [python, pyi]

# Type checking
# ---------- TYPES ----------
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.0
rev: v1.19.1
hooks:
- id: mypy
language_version: python3
additional_dependencies: [types-all]
args: [--ignore-missing-imports, --check-untyped-defs]
exclude: ^(tests/|legacy/|.*\.ipynb)
additional_dependencies:
- types-PyYAML
- types-requests
files: ^src/

# Security checks
# ---------- SECURITY ----------
- repo: https://github.com/PyCQA/bandit
rev: 1.8.0
rev: 1.9.2
hooks:
- id: bandit
args: [-ll, -r, src/]
exclude: ^(tests/|legacy/)
args: [-c, pyproject.toml, -r, src/]
additional_dependencies: ["bandit[toml]"]

# Standard pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=1000] # Increased for model weights
- id: check-ast # Validate Python syntax
- id: check-builtin-literals # Require literal syntax
- id: check-case-conflict # Check for files with case conflicts
- id: check-docstring-first # Ensure docstring before code
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: [--unsafe] # Allow custom YAML tags
- id: debug-statements # Check for debugger imports
- id: detect-private-key # Detect private keys
- id: end-of-file-fixer # Ensure files end with newline
- id: mixed-line-ending # Fix mixed line endings
args: [--fix=lf]
- id: trailing-whitespace # Remove trailing whitespace
args: [--markdown-linebreak-ext=md]

# Docstring formatting
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.7
hooks:
- id: docformatter
args: [
--in-place,
--wrap-summaries=100,
--wrap-descriptions=100,
--make-summary-multi-line,
]
exclude: ^(legacy/|.*\.ipynb)

# Upgrade Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args: [--py38-plus]
exclude: ^(legacy/|.*\.ipynb)

# YAML/JSON/TOML formatting
# ---------- NON-PYTHON FORMAT ----------
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [yaml, json, toml, markdown]
exclude: ^(legacy/)
types_or: [yaml, markdown, json]

# Jupyter notebook cleaning (optional)
- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
# ---------- COMMIT MSG ----------
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.3.0
hooks:
- id: nbstripout
description: Strip output from Jupyter notebooks

# Check for TODO/FIXME comments (warning only)
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.7.4
hooks:
- id: pylint
args: [
--disable=all,
--enable=fixme,
--notes=TODO,FIXME,XXX,
]
exclude: ^(tests/|legacy/)
stages: [manual] # Only run when explicitly called

# Configuration for specific hooks
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [pylint] # Skip slow hooks in CI
submodules: false
- id: conventional-pre-commit
stages: [commit-msg]
1 change: 0 additions & 1 deletion src/datasets/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

import random
from typing import Dict, Tuple, Optional

from PIL import Image, ImageEnhance
import numpy as np
Expand Down
17 changes: 9 additions & 8 deletions src/models/cab.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ def __init__(self, channels, stride=1):
super().__init__()
self.block = nn.Sequential(
nn.Conv2d(
channels, channels, kernel_size=3, stride=stride, padding=1,
groups=channels, bias=False
channels,
channels,
kernel_size=3,
stride=stride,
padding=1,
groups=channels,
bias=False,
),
nn.BatchNorm2d(channels),
nn.ReLU(inplace=True),
Expand All @@ -48,9 +53,7 @@ class PSPModule(nn.Module):

def __init__(self, in_channels, sizes=(1, 3, 6, 8)):
super().__init__()
self.stages = nn.ModuleList([
nn.AdaptiveAvgPool2d((s, s)) for s in sizes
])
self.stages = nn.ModuleList([nn.AdaptiveAvgPool2d((s, s)) for s in sizes])

self.project = nn.Conv2d(
in_channels * (len(sizes) + 1), # +1 for identity
Expand Down Expand Up @@ -98,9 +101,7 @@ def __init__(
self.out_channels = out_channels or in_channels

# Optional spatial reduction
self.pool = (
nn.MaxPool2d(kernel_size=scale) if scale > 1 else nn.Identity()
)
self.pool = nn.MaxPool2d(kernel_size=scale) if scale > 1 else nn.Identity()

# Query / Key / Value projections
self.to_query = nn.Sequential(
Expand Down
Loading
Loading