Skip to content
Open
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
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# IDE files
.vscode/
.idea/
*.swp
*.swo

# Claude Code settings
.claude/*

# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
1,762 changes: 1,762 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[tool.poetry]
name = "pysot"
version = "0.1.0"
description = "Python Single Object Tracking"
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "pysot"}, {include = "toolkit"}]

[tool.poetry.dependencies]
python = "^3.8"
numpy = "*"
opencv-python = "*"
pyyaml = "*"
yacs = "*"
tqdm = "*"
colorama = "*"
matplotlib = "*"
cython = "*"
tensorboardx = "*"

[tool.poetry.group.dev.dependencies]
pytest = "^7.0.0"
pytest-cov = "^4.0.0"
pytest-mock = "^3.10.0"

[tool.poetry.scripts]
test = "pytest:main"
tests = "pytest:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"--strict-markers",
"--strict-config",
"--verbose",
"--cov=pysot",
"--cov=toolkit",
"--cov-report=term-missing",
"--cov-report=html:htmlcov",
"--cov-report=xml:coverage.xml",
"--cov-fail-under=80"
]
markers = [
"unit: marks tests as unit tests (deselect with '-m \"not unit\"')",
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
]

[tool.coverage.run]
source = ["pysot", "toolkit"]
omit = [
"*/tests/*",
"*/test_*",
"*/__pycache__/*",
"*/migrations/*",
"*/venv/*",
"*/.venv/*",
"*/training_dataset/*",
"*/pretrained_models/*",
"*/experiments/*"
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:"
]
show_missing = true
precision = 2

[tool.coverage.html]
directory = "htmlcov"

[tool.coverage.xml]
output = "coverage.xml"
Empty file added tests/__init__.py
Empty file.
108 changes: 108 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import os
import tempfile
import shutil
from pathlib import Path
from unittest.mock import Mock, MagicMock
import pytest
import numpy as np


@pytest.fixture
def temp_dir():
"""Create a temporary directory for tests."""
temp_path = tempfile.mkdtemp()
yield Path(temp_path)
shutil.rmtree(temp_path)


@pytest.fixture
def mock_config():
"""Mock configuration object for testing."""
config = Mock()
config.DATASET = Mock()
config.MODEL = Mock()
config.TRAIN = Mock()
config.TEST = Mock()
return config


@pytest.fixture
def sample_image():
"""Create a sample image for testing."""
return np.random.randint(0, 255, (240, 320, 3), dtype=np.uint8)


@pytest.fixture
def sample_bbox():
"""Create a sample bounding box for testing."""
return [50, 50, 100, 100] # x, y, width, height


@pytest.fixture
def mock_tracker():
"""Mock tracker object for testing."""
tracker = Mock()
tracker.init = Mock()
tracker.track = Mock(return_value={'bbox': [50, 50, 100, 100], 'best_score': 0.8})
return tracker


@pytest.fixture
def mock_model():
"""Mock model object for testing."""
model = Mock()
model.forward = Mock()
model.eval = Mock()
model.train = Mock()
return model


@pytest.fixture
def sample_dataset_config():
"""Sample dataset configuration for testing."""
return {
'name': 'test_dataset',
'root': '/tmp/test_data',
'anno': '/tmp/test_data/annotations.json'
}


@pytest.fixture
def mock_video_data():
"""Mock video data for testing."""
return {
'frames': [f'frame_{i:06d}.jpg' for i in range(10)],
'gt_bbox': [[50 + i, 50 + i, 100, 100] for i in range(10)],
'video_name': 'test_video'
}


@pytest.fixture(autouse=True)
def clean_environment():
"""Clean environment variables before each test."""
original_env = os.environ.copy()
yield
os.environ.clear()
os.environ.update(original_env)


@pytest.fixture
def mock_logger():
"""Mock logger for testing."""
logger = Mock()
logger.info = Mock()
logger.warning = Mock()
logger.error = Mock()
logger.debug = Mock()
return logger


@pytest.fixture
def sample_anchor_config():
"""Sample anchor configuration for testing."""
return {
'stride': 8,
'ratios': [0.33, 0.5, 1, 2, 3],
'scales': [8],
'anchor_num': 5
}
Empty file added tests/integration/__init__.py
Empty file.
Loading