TAS is a Python 3.14 (cp314) video-enhancement CLI and After Effects server for upscale, interpolation, restore/denoise, dedup, depth, segmentation, object detection, stabilization, autoclip, and motion blur. Backends: CUDA, TensorRT, DirectML, OpenVINO, NCNN, and partial MPS. The .jsx UI is in another repo. Version: src/version.py.
python main.py --input <video> --output <video> [--upscale --interpolate --restore --dedup ...]
python -m pytest tests/ -q
python -m pytest tests/test_encodingSettings.py -q
python build.py- CLI definitions/choices:
src/cli/parser.py; validation:src/cli/validator.py; full reference:PARAMETERS.MD. - Tests needing torch/cv2/nelux use
importorskip. build.pydownloads portable Python 3.14.5, installs dependencies, and copiessrctodist-portable/main/; seeBUILD.md(--developredirects output).
- Entry:
main.py→VideoProcessor.start()initializes models viasrc/initializeModels.py, creates I/O buffers, then runs read/process/write withThreadPoolExecutor. - Standard frame path in
processFrame(): decode → dedup → restore → interpolate↔upscale → encode.--interpolate_firstselects the order. - Specialized autoclip/depth/segment/obj_detect/stabilize/motion_blur operations bypass that loop through
_selectProcessingMethod(); their drivers are insrc/initializeModels.py. initializeModels()matches backend-suffixed method strings, lazy-imports the backend, and returns inference callables.- I/O:
src/io/ffmpegSettings.py.BuildBufferusesnelux.VideoReader;createWriteBuffer()selectsNeluxWriteBufferor legacy FFmpeg-subprocessWriteBuffer. Nelux handles audio/subtitle passthrough in_setupPassthroughand needs FFmpeg DLLs registered bysrc/infra/getFFMPEG.py. requirements.txtpinsnelux==0.12.7; on cu132, verifyimport neluxbecause a wheel can be torch-ABI-incompatible.
| Capability | Implementation | Backends/details |
|---|---|---|
| Upscale | src/upscale/ |
CUDA, TRT, DML, OpenVINO, NCNN, MPS |
| Interpolate | src/interpolate/ |
RIFE; CUDA, TRT, DML, OpenVINO, NCNN, MPS |
| Restore | src/unifiedRestore.py |
CUDA, TRT, DML, OpenVINO, Maxine, MPS |
| Dedup | src/dedup/dedup.py |
CUDA/CPU SSIM, MSE, flownets; --dedup_sens default 35 maps to SSIM 1-s/1000, flownets s/100 |
| Depth | src/depth/depth.py, src/depth/backends/ |
CUDA, TRT, DML; includes temporal VideoDepthAnything |
| Segment | src/segment/animeSegment.py |
CUDA, TRT, DML, OpenVINO |
| Object detect | src/objectDetection/objectDetection.py |
CUDA, TRT, DML |
| Autoclip | src/autoclip/ |
PySceneDetect CPU, TRT, DML, TransNetV2 |
| Stabilize | src/stabilize/ |
SuperPoint with ORB/LK fallback |
| Motion blur | src/motionBlur.py |
MotionBlurPipeline |
URL input is handled by src/ytdlp.py.
- Add a model = TWO edits: add its weight mapping to
src/model/downloadModels.py:modelsMap()and its CLI choice tosrc/cli/parser.py.modelsList()is the canonical method registry used by--offline. - Add a backend: add a sibling backend class, a
matcharm insrc/initializeModels.py, CLI choices, andmodelsList()/modelsMap()entries. Never rewrite the CUDA path. - Backend classes follow convention, not an ABC: dashless class suffixes (
UniversalPytorch/UniversalTensorRT/UniversalDirectML/UniversalNCNN/UniversalPytorchMPS;RifeCuda/RifeTensorRT/etc.) implementing__call__()andhandleModel(). Method strings alone use-<backend>. - OpenVINO is normally handled inside the DirectML/ORT class; only Segment has
AnimeSegmentOpenVino. Model-specific exceptions includeAnimeSR*,ArtCNN*,DistilDRBA*,NvidiaVSR, andDepthGuidedRife*. - Weights:
modelsMap()resolves name/scale/dtype;resolveWeightPath()usesweights/{model}/. TRT/DML/OpenVINO useweights/{model}-onnx/, except RIFE keeps its base folder. Downloads come from TAS-Models-Host. - Output naming:
src/io/inputOutputHandler.py:generateOutputName(); encoders:src/io/encodingSettings.py:matchEncoder()plus mirrored CLI choices. - ONNX export:
tools/onnxConverter.py; TensorRT engine build/cache:src/model/trtHandler.py. - Global runtime state:
src/constants.py(WHEREAMIRUNFROM,SYSTEM,FFMPEGPATH,FFPROBEPATH,METADATAPATH,ADOBE,AUDIO), initialized by CLI startup/validation and imported ascs. - Dependencies/FFmpeg/hardware:
src/infra/{dependencyHandler,getFFMPEG,checkSpecs}.py. - AE bridge/preview/presets:
src/server/{aeComms,previewSettings,presetLogic}.py; metadata:src/io/getVideoMetadata.py. - Logs:
main()setscs.LOG_PATHto per-processTAS-Log-<pid>.log;src/infra/logAndPrint.pywraps stdlib logging but does not choose the path.
src/utils/ contains compatibility shims; new code should import the canonical modules above.
Do not read, search, summarize, lint, or modify these trees unless the task explicitly targets that model or a traceback enters it:
src/spandrel/,src/gmfss/,src/rifearches/src/depth/{distillanydepth,depth_anything_3,video_depth_anything,dinov2_layers}/
src/spandrel/ is the in-repo fork of TNTwise/spandrel at e747f27 (adding_extra_archs), not a submodule; provenance is in src/spandrel/NOTICE.md. It is exposed through src/spandrelCompat.py. Restrictive spandrel_extra_arches code was removed. Keep architecture changes ONNX-exportable and FP16-capable. Other model code lives in src/rifearches/, src/gmfss/, and src/extraArches/; torch.fx optimization lives in src/model/modelOptimizer.py.
- Ruff config:
pyproject.toml; CI pins 0.15.16. Before committing, runruff check --fixandruff format. - Ruff rules:
E,F,I,UP,B; formatter owns line length. Vendored exclusions are declared inpyproject.toml; keep them diff-clean against upstream. - No mypy or pre-commit. CI:
tests.yaml, blockinglint.yaml, platform build workflows, andprune-releases.yml. - Dependencies:
requirements.txtandextra-requirements-{windows,windows-lite,linux,linux-lite,macos}.txt. - Several cp314 wheels (TensorRT fork, ONNX Runtime OpenVINO, nelux) come from the
NevermindNilas/TAS-Models-Hostmainrelease; plain PyPI is insufficient for a full install.
- No AI co-author or “Generated with Claude” commit trailer.
- ONNX models ship real paired FP16/FP32 files selected by
half; never relabel FP32 as FP16. CUDA.pthmodels may use runtime.half(). - ONNX/DML returns CPU tensors; CUDA keeps tensors on GPU and may use CUDA graphs/streams. Preserve device placement in shared code.
- Spandrel normalization: compute statistics in FP32, then cast back; already applied to PLKSR/NAFNet/SPAN.
- For optimization,
channels_last/torch.compilealready exist; prioritize architectural/kernel gains while preserving weights and output parity. - Benchmark against a snapshot of the original unedited code on a warm, otherwise-idle GPU; report FPS, VRAM, and parity.
- For bugs/reviews, read every relevant caller, discard false positives explicitly, prove changes with before/after tests, and update
CHANGELOG.MD. - Never load the full large changelog for orientation; grep the relevant entry.