transformers-knn-adapter 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- transformers_knn_adapter-0.2.0/.devcontainer/devcontainer.json +27 -0
- transformers_knn_adapter-0.2.0/.github/workflows/publish.yml +37 -0
- transformers_knn_adapter-0.2.0/.github/workflows/release-please.yml +22 -0
- transformers_knn_adapter-0.2.0/.github/workflows/tests.yml +56 -0
- transformers_knn_adapter-0.2.0/.gitignore +8 -0
- transformers_knn_adapter-0.2.0/.release-please-config.json +14 -0
- transformers_knn_adapter-0.2.0/.release-please-manifest.json +3 -0
- transformers_knn_adapter-0.2.0/AGENTS.md +64 -0
- transformers_knn_adapter-0.2.0/CHANGELOG.md +19 -0
- transformers_knn_adapter-0.2.0/LICENSE +21 -0
- transformers_knn_adapter-0.2.0/PKG-INFO +94 -0
- transformers_knn_adapter-0.2.0/README.md +76 -0
- transformers_knn_adapter-0.2.0/pyproject.toml +45 -0
- transformers_knn_adapter-0.2.0/src/transformers_knn_adapter/__init__.py +19 -0
- transformers_knn_adapter-0.2.0/src/transformers_knn_adapter/knn_image_pipeline.py +818 -0
- transformers_knn_adapter-0.2.0/tests/test_knn_pipeline.py +561 -0
- transformers_knn_adapter-0.2.0/uv.lock +2828 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hf-extender",
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
|
|
4
|
+
"features": {
|
|
5
|
+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
|
|
6
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
|
7
|
+
"ghcr.io/devcontainers/features/python:1": {},
|
|
8
|
+
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {},
|
|
9
|
+
"ghcr.io/jsburckhardt/devcontainer-features/codex:1": {},
|
|
10
|
+
"ghcr.io/nils-geistmann/devcontainers-features/zsh:0": {}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
},
|
|
14
|
+
"containerEnv": {
|
|
15
|
+
"UV_PROJECT_ENVIRONMENT": "/tmp/uv-venv",
|
|
16
|
+
"UV_CACHE_DIR": "/tmp/uv-cache"
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
"customizations": {
|
|
20
|
+
"vscode": {
|
|
21
|
+
"extensions": [
|
|
22
|
+
"openai.chatgpt",
|
|
23
|
+
"github.vscode-github-actions"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
pypi:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment: pypi
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v5
|
|
29
|
+
|
|
30
|
+
- name: Build package
|
|
31
|
+
run: uv build
|
|
32
|
+
|
|
33
|
+
- name: Verify distributions
|
|
34
|
+
run: uvx twine check dist/*
|
|
35
|
+
|
|
36
|
+
- name: Publish to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: release-please
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
release-please:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Run release-please
|
|
18
|
+
uses: googleapis/release-please-action@v4
|
|
19
|
+
with:
|
|
20
|
+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
|
21
|
+
config-file: .release-please-config.json
|
|
22
|
+
manifest-file: .release-please-manifest.json
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
pytest:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
env:
|
|
13
|
+
UV_CACHE_DIR: .uv-cache
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
|
|
28
|
+
- name: Install uv
|
|
29
|
+
uses: astral-sh/setup-uv@v5
|
|
30
|
+
|
|
31
|
+
- name: Cache uv downloads
|
|
32
|
+
uses: actions/cache@v4
|
|
33
|
+
with:
|
|
34
|
+
path: ${{ env.UV_CACHE_DIR }}
|
|
35
|
+
key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
|
|
36
|
+
restore-keys: |
|
|
37
|
+
uv-${{ runner.os }}-${{ matrix.python-version }}-
|
|
38
|
+
uv-${{ runner.os }}-
|
|
39
|
+
|
|
40
|
+
- name: Sync dependencies
|
|
41
|
+
run: uv sync --dev
|
|
42
|
+
|
|
43
|
+
- name: Run ruff
|
|
44
|
+
run: uv run ruff check .
|
|
45
|
+
|
|
46
|
+
- name: Run pytest
|
|
47
|
+
run: uv run pytest -q
|
|
48
|
+
|
|
49
|
+
- name: Build wheel
|
|
50
|
+
run: uv build --wheel
|
|
51
|
+
|
|
52
|
+
- name: Install smoke test
|
|
53
|
+
run: |
|
|
54
|
+
uv venv --clear /tmp/install-smoke
|
|
55
|
+
uv pip install --python /tmp/install-smoke/bin/python dist/*.whl
|
|
56
|
+
/tmp/install-smoke/bin/python -c "import transformers_knn_adapter; print('install-ok')"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
|
3
|
+
"release-type": "python",
|
|
4
|
+
"include-component-in-tag": false,
|
|
5
|
+
"packages": {
|
|
6
|
+
".": {
|
|
7
|
+
"package-name": "transformers_knn_adapter",
|
|
8
|
+
"changelog-path": "CHANGELOG.md",
|
|
9
|
+
"extra-files": [
|
|
10
|
+
"pyproject.toml"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Commit Convention
|
|
4
|
+
|
|
5
|
+
Use [Conventional Commits](https://www.conventionalcommits.org/) for all commits and PR titles.
|
|
6
|
+
|
|
7
|
+
Required format:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
<type>(<optional-scope>): <short imperative summary>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Examples:
|
|
14
|
+
|
|
15
|
+
- `feat(pipeline): add stratified sampling for eval`
|
|
16
|
+
- `fix(ci): run ruff before pytest`
|
|
17
|
+
- `docs(readme): add train and eval usage examples`
|
|
18
|
+
- `test(knn): cover grid-search parameter validation`
|
|
19
|
+
- `chore(deps): bump transformers to latest compatible version`
|
|
20
|
+
|
|
21
|
+
## Allowed Types
|
|
22
|
+
|
|
23
|
+
- `feat`: new user-facing functionality
|
|
24
|
+
- `fix`: bug fix
|
|
25
|
+
- `docs`: documentation-only changes
|
|
26
|
+
- `test`: add/update tests
|
|
27
|
+
- `refactor`: code restructuring without behavior change
|
|
28
|
+
- `perf`: performance improvement
|
|
29
|
+
- `build`: packaging/build system changes
|
|
30
|
+
- `ci`: CI/CD workflow changes
|
|
31
|
+
- `chore`: maintenance that does not fit above
|
|
32
|
+
|
|
33
|
+
## Breaking Changes
|
|
34
|
+
|
|
35
|
+
For breaking changes, use either:
|
|
36
|
+
|
|
37
|
+
- `feat!:` / `fix!:` syntax, or
|
|
38
|
+
- `BREAKING CHANGE:` in the commit body
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
|
|
42
|
+
- `feat!: rename pipeline factory arguments`
|
|
43
|
+
|
|
44
|
+
## Scope Guidance
|
|
45
|
+
|
|
46
|
+
Prefer one of these scopes when relevant:
|
|
47
|
+
|
|
48
|
+
- `pipeline`
|
|
49
|
+
- `knn`
|
|
50
|
+
- `tests`
|
|
51
|
+
- `ci`
|
|
52
|
+
- `packaging`
|
|
53
|
+
- `docs`
|
|
54
|
+
|
|
55
|
+
## Additional Rules
|
|
56
|
+
|
|
57
|
+
- Keep subject line <= 72 characters.
|
|
58
|
+
- Use imperative mood (`add`, `fix`, `remove`), not past tense.
|
|
59
|
+
- Do not end subject line with a period.
|
|
60
|
+
- Squash/fixup local commits before merge when practical.
|
|
61
|
+
|
|
62
|
+
## Why
|
|
63
|
+
|
|
64
|
+
This repository uses automated release/versioning workflows. Conventional Commits keep changelogs and semantic version bumps predictable.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This changelog is automatically managed by release-please from commits merged into `main`.
|
|
6
|
+
|
|
7
|
+
## [0.2.0](https://github.com/dimidagd/transformers-knn-adapter/compare/v0.1.0...v0.2.0) (2026-03-05)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **cli:** add infer mode for single and batched image prediction ([47a291b](https://github.com/dimidagd/transformers-knn-adapter/commit/47a291b9156ad63d9263430366aded4687a8b16b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Documentation
|
|
16
|
+
|
|
17
|
+
* **readme:** add infer command usage example ([6b01105](https://github.com/dimidagd/transformers-knn-adapter/commit/6b01105379de1d4edc66294eaddd460c301352de))
|
|
18
|
+
|
|
19
|
+
## [Unreleased]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 transformers-knn-adapter contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: transformers_knn_adapter
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Hugging Face Transformers image embedding adapter with a scikit-learn KNN classification head.
|
|
5
|
+
Author: transformers-knn-adapter contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: datasets
|
|
10
|
+
Requires-Dist: joblib
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: pillow
|
|
13
|
+
Requires-Dist: scikit-learn
|
|
14
|
+
Requires-Dist: torch
|
|
15
|
+
Requires-Dist: tqdm
|
|
16
|
+
Requires-Dist: transformers
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# transformers-knn-adapter
|
|
20
|
+
|
|
21
|
+
`transformers_knn_adapter` extends Hugging Face image models by attaching a scikit-learn KNN classifier on top of transformer embeddings.
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
- Python 3.11+
|
|
26
|
+
- `uv`
|
|
27
|
+
|
|
28
|
+
## Setup
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv sync --dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Run Tests
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv run pytest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Train
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline train \
|
|
44
|
+
--model microsoft/resnet-50 \
|
|
45
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
46
|
+
--dataset timm/mini-imagenet \
|
|
47
|
+
--split train \
|
|
48
|
+
--max-samples 1000 \
|
|
49
|
+
--shuffle \
|
|
50
|
+
--grid-search \
|
|
51
|
+
--grid-search-splits 3 \
|
|
52
|
+
--grid-search-repeats 2 \
|
|
53
|
+
--grid-search-scoring f1_macro
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Evaluate
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline eval \
|
|
60
|
+
--model microsoft/resnet-50 \
|
|
61
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
62
|
+
--dataset timm/mini-imagenet \
|
|
63
|
+
--split test \
|
|
64
|
+
--stratified \
|
|
65
|
+
--max-samples 100 \
|
|
66
|
+
--shuffle \
|
|
67
|
+
--batch-size 100
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Inference
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline infer \
|
|
74
|
+
--model microsoft/resnet-50 \
|
|
75
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
76
|
+
--image https://picsum.photos/200 \
|
|
77
|
+
--inference-batch-size 5
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Python API
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from transformers_knn_adapter.knn_image_pipeline import pipeline
|
|
84
|
+
|
|
85
|
+
clf = pipeline(
|
|
86
|
+
"image-classification",
|
|
87
|
+
model_path="microsoft/resnet-50",
|
|
88
|
+
knn_model_path="/tmp/knn/model.joblib",
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Notes
|
|
93
|
+
|
|
94
|
+
Real train/eval runs can download model and dataset artifacts from Hugging Face.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# transformers-knn-adapter
|
|
2
|
+
|
|
3
|
+
`transformers_knn_adapter` extends Hugging Face image models by attaching a scikit-learn KNN classifier on top of transformer embeddings.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python 3.11+
|
|
8
|
+
- `uv`
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uv sync --dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Run Tests
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv run pytest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Train
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline train \
|
|
26
|
+
--model microsoft/resnet-50 \
|
|
27
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
28
|
+
--dataset timm/mini-imagenet \
|
|
29
|
+
--split train \
|
|
30
|
+
--max-samples 1000 \
|
|
31
|
+
--shuffle \
|
|
32
|
+
--grid-search \
|
|
33
|
+
--grid-search-splits 3 \
|
|
34
|
+
--grid-search-repeats 2 \
|
|
35
|
+
--grid-search-scoring f1_macro
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Evaluate
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline eval \
|
|
42
|
+
--model microsoft/resnet-50 \
|
|
43
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
44
|
+
--dataset timm/mini-imagenet \
|
|
45
|
+
--split test \
|
|
46
|
+
--stratified \
|
|
47
|
+
--max-samples 100 \
|
|
48
|
+
--shuffle \
|
|
49
|
+
--batch-size 100
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Inference
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv run python -m transformers_knn_adapter.knn_image_pipeline infer \
|
|
56
|
+
--model microsoft/resnet-50 \
|
|
57
|
+
--knn-model-path /tmp/knn/dinov2_small_mini_imagenet_full.joblib \
|
|
58
|
+
--image https://picsum.photos/200 \
|
|
59
|
+
--inference-batch-size 5
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Python API
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from transformers_knn_adapter.knn_image_pipeline import pipeline
|
|
66
|
+
|
|
67
|
+
clf = pipeline(
|
|
68
|
+
"image-classification",
|
|
69
|
+
model_path="microsoft/resnet-50",
|
|
70
|
+
knn_model_path="/tmp/knn/model.joblib",
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Notes
|
|
75
|
+
|
|
76
|
+
Real train/eval runs can download model and dataset artifacts from Hugging Face.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "transformers_knn_adapter"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Hugging Face Transformers image embedding adapter with a scikit-learn KNN classification head."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "transformers-knn-adapter contributors" }]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"transformers",
|
|
15
|
+
"datasets",
|
|
16
|
+
"scikit-learn",
|
|
17
|
+
"numpy",
|
|
18
|
+
"torch",
|
|
19
|
+
"pillow",
|
|
20
|
+
"joblib",
|
|
21
|
+
"tqdm",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = [
|
|
26
|
+
"ruff",
|
|
27
|
+
"pytest",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel]
|
|
31
|
+
packages = ["src/transformers_knn_adapter"]
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
testpaths = ["tests"]
|
|
35
|
+
python_files = ["test_*.py"]
|
|
36
|
+
addopts = "-q"
|
|
37
|
+
|
|
38
|
+
[tool.ruff]
|
|
39
|
+
target-version = "py310"
|
|
40
|
+
line-length = 120
|
|
41
|
+
src = ["src", "tests"]
|
|
42
|
+
|
|
43
|
+
[tool.ruff.lint]
|
|
44
|
+
select = ["E", "F", "I"]
|
|
45
|
+
ignore = ["E501"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Public package exports for transformers_knn_adapter."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
__all__ = ["KNNImageClassificationPipeline", "pipeline"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def __getattr__(name: str) -> Any:
|
|
11
|
+
if name in __all__:
|
|
12
|
+
from .knn_image_pipeline import KNNImageClassificationPipeline, pipeline
|
|
13
|
+
|
|
14
|
+
exports = {
|
|
15
|
+
"KNNImageClassificationPipeline": KNNImageClassificationPipeline,
|
|
16
|
+
"pipeline": pipeline,
|
|
17
|
+
}
|
|
18
|
+
return exports[name]
|
|
19
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|