Text-to-Image
Diffusers
Safetensors
GGUF
English
TeverationPipeline
teveration
image-to-image
depth-estimation
image-segmentation
ternary
quantized
jeveration
qwen3.5
bonsai
comfyui
custom_code
conversational
Run this model with HF Jobs
Run DmitrofNET/Teveration-1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/DmitrofNET/Teveration-1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/DmitrofNET/Teveration-1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use DmitrofNET/Teveration-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use DmitrofNET/Teveration-1 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("DmitrofNET/Teveration-1", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use DmitrofNET/Teveration-1 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf DmitrofNET/Teveration-1 # Run inference directly in the terminal: llama cli -hf DmitrofNET/Teveration-1
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf DmitrofNET/Teveration-1 # Run inference directly in the terminal: llama cli -hf DmitrofNET/Teveration-1
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf DmitrofNET/Teveration-1 # Run inference directly in the terminal: ./build/bin/llama cli -hf DmitrofNET/Teveration-1
Use Docker
docker model run hf.co/DmitrofNET/Teveration-1
- Llama new
- LM Studio
- Jan
- Draw Things
- DiffusionBee
- Ollama
How to use DmitrofNET/Teveration-1 with Ollama:
ollama run hf.co/DmitrofNET/Teveration-1
- Unsloth Desktop
- Pi
How to use DmitrofNET/Teveration-1 with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DmitrofNET/Teveration-1
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "DmitrofNET/Teveration-1" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use DmitrofNET/Teveration-1 with Docker Model Runner:
docker model run hf.co/DmitrofNET/Teveration-1
- Lemonade
How to use DmitrofNET/Teveration-1 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull DmitrofNET/Teveration-1
Run and chat with the model
lemonade run user.Teveration-1-{{QUANT_TAG}}List all available models
lemonade list
- Hermes Agent
How to use DmitrofNET/Teveration-1 with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DmitrofNET/Teveration-1
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default DmitrofNET/Teveration-1
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use DmitrofNET/Teveration-1 with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DmitrofNET/Teveration-1
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "DmitrofNET/Teveration-1" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Teveration 1: GGUF files, engine bindings, model card
Browse filesFiles changed (35)
- .gitattributes+6
- BENCHMARKS.md+32-39
- LICENSE-WEIGHTS.md+10-11
- NOTICE+4-1
- README.md+108-76
- THIRD_PARTY_NOTICES.md+20-8
- adapter.safetensors → Teveration-1-adapter-Q4_0.ggufRenamed+2-2
- backbone.safetensors → Teveration-1-adapter-Q6_mix.ggufRenamed+2-2
- Teveration-1-adapter-Q8_0.ggufAdded+3
- codec.safetensors → Teveration-1-backbone-PTQ1_0.ggufRenamed+2-2
- head.safetensors → Teveration-1-image-Q4_0.ggufRenamed+2-2
- Teveration-1-mmproj-Q8_0.ggufAdded+3
- benchmark_metrics.json+229-74
- config.jsonAdded+16
- images/dense.jpg
- images/i2i.jpg
- images/t2i_1.jpg
- images/t2i_2.jpg
- images/t2i_3.jpg
- images/t2i_4.jpg
- manifest.jsonDeleted-64
- qwen/tokenizer.json → model.safetensorsRenamed+2-2
- model_index.jsonAdded+4
- modeling_teveration.pyAdded+66
- pipeline.pyAdded+369
- qwen/chat_template.jinjaDeleted-154
- qwen/config.jsonDeleted-104
- qwen/merges.txtDeleted
- qwen/preprocessor_config.jsonDeleted-21
- qwen/tokenizer_config.jsonDeleted-305
- qwen/video_preprocessor_config.jsonDeleted-21
- qwen/vocab.jsonDeleted
- tatitok/config.jsonDeleted-28
- teveration_engine.pyAdded+308
- vision.safetensorsDeleted-3
39 unmodified lines40414239 unmodified linesimages/t2i_2.jpg filter=lfs diff=lfs merge=lfs -textimages/t2i_3.jpg filter=lfs diff=lfs merge=lfs -textimages/t2i_4.jpg filter=lfs diff=lfs merge=lfs -text39 unmodified lines40414243444546474839 unmodified linesimages/t2i_2.jpg filter=lfs diff=lfs merge=lfs -textimages/t2i_3.jpg filter=lfs diff=lfs merge=lfs -textimages/t2i_4.jpg filter=lfs diff=lfs merge=lfs -textTeveration-1-adapter-Q4_0.gguf filter=lfs diff=lfs merge=lfs -textTeveration-1-adapter-Q6_mix.gguf filter=lfs diff=lfs merge=lfs -textTeveration-1-adapter-Q8_0.gguf filter=lfs diff=lfs merge=lfs -textTeveration-1-backbone-PTQ1_0.gguf filter=lfs diff=lfs merge=lfs -textTeveration-1-image-Q4_0.gguf filter=lfs diff=lfs merge=lfs -textTeveration-1-mmproj-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455# Benchmark resultsMeasured on NVIDIA GeForce RTX 4070, torch 2.7.1+cu126, with `benchmarks/run.py`. 32 text-to-image pictures, 8 image-to-image pictures, 4 rooms for dense prediction. Every number compares against the original model's own output for the same request, random state and sampling draw; this is a small-sample fidelity check, not GenEval, DPG or NYUv2 ground truth.## Quality| | CLIP text score | T2I similarity to original (worst) | I2I similarity to original (worst) | Segmentation agreement | Depth difference | Normal difference ||---|---|---|---|---|---|---|| Jeveration (original) | 0.3213 | 1.000 (1.000) | 1.000 (1.000) | 100.0% | 0.0% | 0.0 deg || Teveration 1 | 0.3220 | 0.964 (0.888) | 0.973 (0.945) | 95.0% | 3.6% | 11.2 deg || original codes, Teveration decoders | 0.3220 | 0.999 (0.996) | 0.999 (0.999) | - | - | - |Pixel-level and code-level detail:| | T2I PSNR to original | I2I PSNR to original | T2I code KL | I2I code KL | T2I same codes | I2I same codes ||---|---|---|---|---|---|---|| Jeveration (original) | 138.1 dB | 138.1 dB | 0.000 | 0.000 | 100% | 100% || Teveration 1 | 15.5 dB | 17.6 dB | 1.069 | 4.073 | 15% | 14% || original codes, Teveration decoders | 41.3 dB | 45.5 dB | - | - | - | - |Image-to-image per input (similarity to original, PSNR):| Input | Similarity | PSNR ||---|---|---|| hed:hed_puppy | 0.974 | 15.4 dB || hed:hed_tulips | 0.984 | 19.1 dB || depth:depth_pancakes | 0.992 | 11.8 dB || colorize:gray_burger | 0.945 | 22.2 dB || colorize:gray_pancakes | 0.990 | 23.0 dB || anime:photo_boathouse | 0.960 | 16.4 dB || ghibli:photo_pine | 0.963 | 15.9 dB || watercolor:photo_snowcabin | 0.974 | 16.6 dB |## Size| Original stack | GB | | Teveration 1 | GB ||---|---|---|---|---|| Qwen3.5-4B | 9.32 | | adapter.safetensors | 0.50 || jeveration.pt | 4.01 | | backbone.safetensors | 0.92 || decoder512.pt | 1.22 | | codec.safetensors | 0.40 || source_decoder512.pt | 1.25 | | head.safetensors | 0.43 || CLIP ViT-L/14-336 | 1.71 | | vision.safetensors | 0.37 || TA-TiTok VQ-128 | 1.56 | | tokenizer and configuration files | 0.02 || **total** | **19.08** | | **total** | **2.64** |Teveration 1 is 7.2x smaller on disk.## Speed and memory| | Load time | Seconds per forward pass (batch 1) | Peak GPU memory, generator ||---|---|---|---|| Jeveration (original) | 54 s | 0.51 | 11.4 GB || Teveration 1 | 11 s | 0.46 | 11.2 GB |Both run the same dense bfloat16 network at run time (PyTorch linear-attention path), so speed and memory match; the original is loaded here with its LoRA merged, which is what lets it fit a 12 GB card at all.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748# Benchmark resultsMeasured on NVIDIA GeForce RTX 4070 with `benchmarks/run.py`: 32 text-to-image pictures, 8 image-to-image pictures, 4 rooms for dense prediction. Teveration runs in its engine from the released GGUF files; the original runs in PyTorch. Every number compares against the original model's own output for the same request, random state and sampling draw. This is a small-sample fidelity check, not GenEval, DPG or NYUv2 ground truth.## Quality| | Size | CLIP text score | T2I similarity to original (worst) | I2I similarity to original (worst) | Segmentation agreement | Depth difference | Normal difference ||---|---|---|---|---|---|---|---|| Jeveration (original) | 19.08 GB | 0.3213 | 1.000 (1.000) | 1.000 (1.000) | 100.0% | 0.0% | 0.0 deg || Teveration 1 small | 2.59 GB | 0.3160 | 0.961 (0.892) | 0.973 (0.928) | 96.1% | 3.7% | 8.8 deg || Teveration 1 balanced | 2.79 GB | 0.3232 | 0.965 (0.851) | 0.969 (0.934) | 96.6% | 2.4% | 7.7 deg || original codes, Teveration decoder | | 0.3217 | 0.999 (0.996) | 0.999 (0.999) | - | - | - || Teveration 1 high | 3.08 GB | 0.3222 | 0.969 (0.920) | 0.968 (0.943) | 97.1% | 2.0% | 6.5 deg |Pixel-level and code-level detail:| | T2I PSNR to original | I2I PSNR to original | T2I code KL | I2I code KL | T2I same codes | I2I same codes ||---|---|---|---|---|---|---|| Jeveration (original) | 138.1 dB | 138.1 dB | 0.000 | 0.000 | 100% | 100% || Teveration 1 small | 16.0 dB | 19.8 dB | 0.794 | 2.561 | 20% | 21% || Teveration 1 balanced | 16.5 dB | 18.9 dB | 0.558 | 1.998 | 26% | 28% || original codes, Teveration decoder | 42.0 dB | 45.9 dB | - | - | - | - || Teveration 1 high | 16.7 dB | 20.2 dB | 0.420 | 1.245 | 30% | 32% |## Speed and memory| | Runs on | Load | Text-to-image | Image-to-image | Dense prediction | GPU memory | Process RAM ||---|---|---|---|---|---|---|---|| Jeveration (original) | PyTorch, CUDA | 62 s | 0.42 s (generator only) | | | 11.4 GB (generator only) | || Teveration 1 small | engine, CUDA0 | 5.8 s | 0.18 s per picture | 0.30 s | 0.91 s | 4.8 GB | 2.3 GB || Teveration 1 balanced | engine, CUDA0 | 5.0 s | 0.18 s per picture | 0.30 s | 0.92 s | 4.7 GB | 2.3 GB || Teveration 1 high | engine, CUDA0 | 5.0 s | 0.17 s per picture | 0.30 s | 0.91 s | 4.7 GB | 2.3 GB || Teveration 1 balanced, text-to-image only | engine, CUDA0 | 4.7 s | 0.17 s per picture | | | 4.0 GB | 2.1 GB || Teveration 1 balanced, CPU only | engine, CPU | 1.8 s | 8.56 s per picture | 13.60 s | 16.55 s | | 4.2 GB |Teveration's times are complete pictures (backbone, head and decoder), measured in a process without PyTorch (`benchmarks/system.py`). GPU memory is the growth of the card's used memory from before loading to after every task has run, read from nvidia-smi. Dense prediction is three backbone passes (segmentation, depth, normals). The CPU row used half the logical cores.## Size| Original stack | GB | | Teveration 1 file | GB ||---|---|---|---|---|| Qwen3.5-4B | 9.32 | | Teveration-1-backbone-PTQ1_0.gguf | 0.95 || jeveration.pt | 4.01 | | Teveration-1-image-Q4_0.gguf | 0.72 || decoder512.pt | 1.22 | | Teveration-1-mmproj-Q8_0.gguf | 0.37 || source_decoder512.pt | 1.25 | | Teveration-1-adapter-Q4_0.gguf | 0.55 || CLIP ViT-L/14-336 | 1.71 | | Teveration-1-adapter-Q6_mix.gguf | 0.75 || TA-TiTok VQ-128 | 1.56 | | Teveration-1-adapter-Q8_0.gguf | 1.04 || **total** | **19.08** | | **backbone + image + mmproj + one adapter** | **2.59** / **2.79** / **3.08** |
123456789 unmodified lines181920212223242526272829303132# License of the model files, figures and documentationThe Teveration 1 model files (`backbone.safetensors`, `adapter.safetensors`, `head.safetensors`, `vision.safetensors`,`codec.safetensors`, `manifest.json`), the figures in `assets/` and `benchmarks/results/`, and the documentation areCopyright 2026 DmitrofNET and licensed under the[Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/legalcode) (CC BY 4.0).You may copy, redistribute, convert, quantize, fine-tune and build on them, also commercially, as long as you give9 unmodified lineswhich permits derivative works under other terms provided its own conditions are met; this section and `NOTICE` are therequired statement of origin and of changes.| Part of Teveration 1 | Derived from | Change ||---|---|---|| `backbone.safetensors`, ternary matrices and embedding | Ternary Bonsai 2 4B (Prism ML), itself built from Qwen3.5-4B (Alibaba Cloud) | repacked from 2 bits to 1.6 bits per weight, values unchanged || `backbone.safetensors`, small tensors | Qwen3.5-4B (Alibaba Cloud) | stored in half precision || `adapter.safetensors` | Jeveration LoRA (The Jeveration Authors), Qwen3.5-4B, Ternary Bonsai 2 4B | re-fitted in closed form to the ternary base at rank 512, factors rounded to 4 bits || `head.safetensors` | Jeveration checkpoint `jeveration.pt` | large matrices rounded to 4 bits, the rest in half precision || `vision.safetensors` | Qwen3.5-4B vision tower | rounded to 8 bits || `codec.safetensors` | Jeveration `source_decoder512.pt`, CLIP ViT-L/14-336 text tower (OpenAI), TA-TiTok VQ-128 codebook (Bytedance) | decoder rounded to 8 bits, CLIP text tower to 4 bits, vision tower of CLIP removed || `model/qwen/*`, `model/tatitok/config.json` | Qwen3.5-4B, TA-TiTok | unchanged tokenizer and configuration files, under their original Apache 2.0 license |The example inputs in `assets/inputs/` are from the Jeveration repository (Apache 2.0).12345679 unmodified lines171819202122232425262728293031# License of the model files, figures and documentationThe Teveration 1 model files (the `Teveration-1-*.gguf` files), the figures in `assets/` and `benchmarks/results/`, andthe documentation are Copyright 2026 DmitrofNET and licensed under the[Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/legalcode) (CC BY 4.0).You may copy, redistribute, convert, quantize, fine-tune and build on them, also commercially, as long as you give9 unmodified lineswhich permits derivative works under other terms provided its own conditions are met; this section and `NOTICE` are therequired statement of origin and of changes.| File | Derived from | Change ||---|---|---|| `Teveration-1-backbone-PTQ1_0.gguf`, ternary matrices and token embedding | Ternary Bonsai 2 4B (Prism ML), itself built from Qwen3.5-4B (Alibaba Cloud) | none: copied bit for bit from `Ternary-Bonsai-2-4B-PTQ1_0.gguf` || `Teveration-1-backbone-PTQ1_0.gguf`, 225 small tensors | Qwen3.5-4B (Alibaba Cloud) | Bonsai's retrained norm gains and linear-attention state tensors replaced by Qwen's originals, reordered to the GGUF layout || `Teveration-1-adapter-Q4_0.gguf`, `-Q6_mix.gguf`, `-Q8_0.gguf` | Jeveration LoRA (The Jeveration Authors), Qwen3.5-4B, Ternary Bonsai 2 4B | re-fitted in closed form to the ternary base at rank 512; factors rounded to 4 bits, 8 and 4 bits, or 8 bits || `Teveration-1-image-Q4_0.gguf`, head and dense heads | Jeveration checkpoint `jeveration.pt` | matrices rounded to 4 or 8 bits; everything that depends only on the masked share folded into tables || `Teveration-1-image-Q4_0.gguf`, decoder | Jeveration `source_decoder512.pt` | matrices rounded to 8 bits || `Teveration-1-image-Q4_0.gguf`, text tower and codebook | CLIP ViT-L/14-336 text tower (OpenAI), TA-TiTok VQ-128 codebook (Bytedance) | text tower rounded to 4 bits, CLIP's vision tower removed, codebook unchanged || `Teveration-1-mmproj-Q8_0.gguf` | Ternary Bonsai 2 4B (`Ternary-Bonsai-2-4B-mmproj-Q8_0.gguf`), the Qwen3.5-4B vision tower | none: renamed |The example inputs in `assets/inputs/` are from the Jeveration repository (Apache 2.0).
17 unmodified lines1819202122232417 unmodified lines(code: https://github.com/Carol-lyh/Jeveration, weights: https://huggingface.co/linlinlinlinsdada/Jeveration)- Qwen3.5-4B, Copyright 2026 Alibaba Cloud (https://huggingface.co/Qwen/Qwen3.5-4B)- Ternary Bonsai 2 4B, Copyright 2026-present Prism ML, Inc. Created using Bonsai by Prism ML.(https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-mlx-2bit)- TA-TiTok (1d-tokenizer), Copyright 2024 Bytedance Ltd. and/or its affiliates(https://github.com/bytedance/1d-tokenizer)- CLIP ViT-L/14-336, OpenAI, in open_clip format (https://huggingface.co/timm/vit_large_patch14_clip_336.openai)17 unmodified lines1819202122232425262717 unmodified lines(code: https://github.com/Carol-lyh/Jeveration, weights: https://huggingface.co/linlinlinlinsdada/Jeveration)- Qwen3.5-4B, Copyright 2026 Alibaba Cloud (https://huggingface.co/Qwen/Qwen3.5-4B)- Ternary Bonsai 2 4B, Copyright 2026-present Prism ML, Inc. Created using Bonsai by Prism ML.(https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-gguf)- TA-TiTok (1d-tokenizer), Copyright 2024 Bytedance Ltd. and/or its affiliates(https://github.com/bytedance/1d-tokenizer)- CLIP ViT-L/14-336, OpenAI, in open_clip format (https://huggingface.co/timm/vit_large_patch14_clip_336.openai)The engine is built on llama.cpp in PrismML's fork (https://github.com/PrismML-Eng/llama.cpp), MIT license,Copyright (c) 2023-2026 The ggml authors.
2 unmodified lines34567891 unmodified line11121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041 unmodified line1061071081091101111121131141151161171181191201211221239 unmodified lines1331341351361371381391401411421431441451461471481491501511521531546 unmodified lines1611621631641651661671681691701711721731742 unmodified linesbase_model: linlinlinlinsdada/Jeverationbase_model_relation: quantizedpipeline_tag: text-to-imagelibrary_name: teverationlanguage:- entags:1 unmodified line- image-to-image- depth-estimation- image-segmentation- ternary- quantized- jeveration- qwen3.5- bonsai---# Teveration 1**Jeveration in 2.6 GB instead of 19 GB.** A ternary-backbone quantization of[Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration) that keeps every feature of the original:text-to-image, image-to-image (edge map or depth map to image, colorization, anime / Ghibli / watercolor styles) anddense prediction (13-class segmentation, depth, surface normals). Built without any retraining.- Code, build scripts, tests and benchmarks: https://github.com/DmitrofNETDev/Teveration-1- Original model: [linlinlinlinsdada/Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration), paper https://arxiv.org/abs/2611.24738Left of each pair: the original Jeveration. Right: Teveration 1, same prompt, same random state, same sampling draw.These are the first 8 of the 32 benchmark pictures, not a selection.## DownloadOne command, everything (2.64 GB):```bashhf download DmitrofNET/Teveration-1 --local-dir model```Or click a file to download it directly:| File | Size ||---|---|| [backbone.safetensors](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/backbone.safetensors?download=true) | 916 MB || [adapter.safetensors](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/adapter.safetensors?download=true) | 503 MB || [head.safetensors](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/head.safetensors?download=true) | 431 MB || [codec.safetensors](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/codec.safetensors?download=true) | 396 MB || [vision.safetensors](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/vision.safetensors?download=true) | 370 MB |All five are needed, together with the small `qwen/`, `tatitok/` and `manifest.json` files (the `hf download` command and`python -m teveration download` fetch those too). There is one build, so there is no list of quantization variants tochoose from, and no GGUF: the model is not runnable by llama.cpp, Ollama or LM Studio.## Files| File | Size | Content | Bits per weight ||---|---|---|---|| `backbone.safetensors` | 0.92 GB | 200 ternary matrices and the ternary token embedding of the Qwen3.5-4B language model (from PrismML's Ternary Bonsai 2 4B), plus Qwen's small full-precision tensors | 1.73 || `adapter.safetensors` | 0.50 GB | a rank-512 low-rank path for each ternary matrix: Jeveration's LoRA re-fitted to the ternary base | 4.12 || `head.safetensors` | 0.43 GB | image head, decision-token inputs, dense heads | 4.13 and 16 || `vision.safetensors` | 0.37 GB | Qwen3.5-4B vision tower (image-to-image and dense prediction) | 8.12 || `codec.safetensors` | 0.40 GB | 512-px decoder (serves both text-to-image and image-to-image), CLIP text tower, codebook | 8.12 and 4.13 || `qwen/`, `tatitok/` | 0.02 GB | unchanged tokenizer and configuration files | || `manifest.json` | | size and SHA-256 of every file | |Total 2.64 GB. The original stack (Qwen3.5-4B, `jeveration.pt`, two decoders, CLIP, TA-TiTok) is 19.08 GB.All packs are plain safetensors files; the encodings are documented in[docs/FORMAT.md](https://github.com/DmitrofNETDev/Teveration-1/blob/main/docs/FORMAT.md).## UseNeeds Python 3.10+, a CUDA GPU with 12 GB and the `teveration` package from GitHub. The files are not loadable with`diffusers` or plain `transformers`.```bashgit clone https://github.com/DmitrofNETDev/Teveration-1cd Teveration-1pip install torch --index-url https://download.pytorch.org/whl/cu126pip install -e .python -m teveration download # fetches these files into model/ and verifies thempython -m teveration t2i "A lighthouse on a rocky cliff under a stormy sky." --seed 0python -m teveration i2i colorize assets/inputs/gray_burger.jpgpython -m teveration i2i depth assets/inputs/depth_pancakes.png --caption "A stack of fluffy pancakes with blueberries."python -m teveration dense assets/inputs/room_1.png``````pythonfrom teveration import Teverationtev = Teveration("model")images = tev.text_to_image(["An oil painting of sunflowers in a blue ceramic vase."], seed=0) # uint8 [B, 512, 512, 3]images = tev.image_to_image(sources, "colorize", seed=0) # tasks: hed, depth, colorize, anime, ghibli, watercolormaps = tev.dense_predict(pictures) # {"seg", "depth", "normal"}```## EvaluationMeasured from these files on an RTX 4070 with1 unmodified linesame requests with the same random states and sampling draws; each number compares Teveration's output with theoriginal's output for the same request.| | Jeveration (original) | Teveration 1 ||---|---|---|| Download and disk size | 19.08 GB | **2.64 GB** (7.2x smaller) || Text-to-image, CLIP text score (32 pictures) | 0.321 | 0.322 || Text-to-image, similarity to the original's picture (worst case) | 1 | 0.964 (0.888) || Image-to-image, similarity to the original's picture (worst case), 8 pictures | 1 | 0.973 (0.945) || Segmentation, pixels agreeing with the original (4 rooms) | 100% | 95.0% || Depth, difference from the original | 0% | 3.6% || Surface normals, difference from the original | 0° | 11.2° || Decoders alone (original codes, Teveration decoders), PSNR | | 41.3 dB text-to-image, 45.5 dB image-to-image || Load time | 54 s | 11 s || Seconds per forward pass, peak GPU memory | 0.51 s, 11.4 GB | 0.46 s, 11.2 GB |The pictures match their prompts as well as the original's do, but they are not the same pictures: compositions andcolours shift. This is a small-sample fidelity check against the original. GenEval, DPG-Bench, HPS and NYUv29 unmodified lines1. Dead weight removed (4.3 GB): one of the two decoder files is a bit-identical subset of the other, CLIP's vision toweris never used, and only the codebook of the 1.6 GB tokenizer is used.2. The frozen Qwen3.5-4B backbone (9.3 GB) is replaced by PrismML's ternary version of the same model, repacked from 2to 1.6 bits per weight (0.9 GB).3. Jeveration's LoRA cannot be merged and rounded: its update is 2.5 to 4.8 times larger than the base weights. Eachmatrix instead keeps a separate low-rank path, `W = T + U A`, re-fitted in closed form so that it carries both the LoRAand what ternarization removed, weighted by the inputs the matrix sees on calibration prompts. No gradient step.4. The head and the CLIP text tower are rounded to 4 bits in a Hadamard-rotated basis, the vision tower and the decoderto 8 bits. Each choice is the lowest precision that component tolerated when rounded on its own.The full analysis and every measurement:[docs/analysis.md](https://github.com/DmitrofNETDev/Teveration-1/blob/main/docs/analysis.md).## Limits- Run-time memory is not reduced: the packs are unpacked to the dense bfloat16 network of the original (about 10 GB ofGPU memory for the generator). The saving is download and disk size.- Outputs drift from the original's (worst text-to-image similarity 0.888); dense maps differ by a few percent.- No training was done. A distilled successor at about 1.5 GB is planned.- Inherits Jeveration's limits: 512 px output, English prompts, 13 indoor classes for segmentation.6 unmodified linesTeveration 1 is a derivative of [Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration) (The JeverationAuthors), [Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Alibaba Cloud),[Ternary Bonsai 2 4B](https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-mlx-2bit) (created using Bonsai by Prism ML),[TA-TiTok](https://huggingface.co/turkeyju/tokenizer_tatitok_bl128_vq) (Bytedance) and CLIP ViT-L/14-336 (OpenAI), allunder Apache 2.0. Their notices are in `NOTICE` and `THIRD_PARTY_NOTICES.md`; what was changed is listed in`LICENSE-WEIGHTS.md`.```bibtex@software{teveration1,title = {Teveration 1: a ternary-backbone build of the Jeveration image model},author = {DmitrofNET},year = {2026},url = {https://github.com/DmitrofNETDev/Teveration-1}2 unmodified lines34567891 unmodified line11121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291 unmodified line1311321331341351361371381391401411421431441451461471481491509 unmodified lines1601611621631641651661671681691701711721731741751761771781791801811821831841851866 unmodified lines1931941951961971981992002012022032042052062 unmodified linesbase_model: linlinlinlinsdada/Jeverationbase_model_relation: quantizedpipeline_tag: text-to-imagelibrary_name: diffuserslanguage:- entags:1 unmodified line- image-to-image- depth-estimation- image-segmentation- gguf- ternary- quantized- jeveration- qwen3.5- bonsai- comfyui---# Teveration 1**The Jeveration image model in 2.8 GB of GGUF instead of 19 GB, with its own engine.** A ternary-backbonequantization of [Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration) that keeps every feature of theoriginal: text-to-image, image-to-image (edge map or depth map to image, colorization, anime / Ghibli / watercolorstyles) and dense prediction (13-class segmentation, depth, surface normals). Built without any retraining.- Engine, bindings, ComfyUI nodes, build scripts, tests and benchmarks: https://github.com/DmitrofNETDev/Teveration-1- Original model: [linlinlinlinsdada/Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration), paper https://arxiv.org/abs/2611.24738Left of each pair: the original Jeveration. Right: Teveration 1 balanced, same prompt, same random state, same samplingdraw. These are the first 8 of the 32 benchmark pictures, not a selection.## FilesA complete model is the backbone, the image file, **one** adapter and, for image-to-image and dense prediction, themmproj file.| File | Size | Needed for | Content ||---|---|---|---|| [Teveration-1-backbone-PTQ1_0.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-backbone-PTQ1_0.gguf?download=true) | 0.95 GB | everything | the ternary language model (1.75 bits per weight) || [Teveration-1-image-Q4_0.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-image-Q4_0.gguf?download=true) | 0.72 GB | everything | image head, dense heads, decoder, CLIP text tower || [Teveration-1-adapter-Q6_mix.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-adapter-Q6_mix.gguf?download=true) | 0.75 GB | **balanced** (default) | the low-rank path, 8-bit and 4-bit factors || [Teveration-1-adapter-Q4_0.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-adapter-Q4_0.gguf?download=true) | 0.55 GB | small | the low-rank path, 4-bit factors || [Teveration-1-adapter-Q8_0.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-adapter-Q8_0.gguf?download=true) | 1.04 GB | high | the low-rank path, 8-bit factors || [Teveration-1-mmproj-Q8_0.gguf](https://huggingface.co/DmitrofNET/Teveration-1/resolve/main/Teveration-1-mmproj-Q8_0.gguf?download=true) | 0.37 GB | image-to-image, dense prediction | the vision tower |Totals with the vision tower: **2.59 GB** small, **2.79 GB** balanced, **3.08 GB** high. The original stack (Qwen3.5-4B,`jeveration.pt`, two decoders, CLIP, TA-TiTok) is 19.08 GB.You do not have to pick files by hand: every route below downloads what it needs.These GGUF files need the **Teveration engine**. The backbone uses PrismML's ternary tensor type and the image file isan architecture of its own, so stock llama.cpp, Ollama and LM Studio cannot load them (and, being text-chat runtimes,could not return a picture from any model). For a chat front end, run `teveration serve` and use it as the imagebackend (OpenAI images API).## UseThe model runs in the Teveration engine, which keeps the weights packed in memory. No PyTorch is needed to run it. Theengine build for your machine (Windows, Linux, macOS; CUDA, Vulkan, Metal or CPU) is downloaded on first use.### diffusers```pythonfrom diffusers import DiffusionPipelinepipe = DiffusionPipeline.from_pretrained("DmitrofNET/Teveration-1", custom_pipeline="DmitrofNET/Teveration-1", trust_remote_code=True)image = pipe("A lighthouse on a rocky cliff under a stormy sky.", seed=0).images[0]image = pipe(image=photo, task="ghibli").images[0] # hed, depth, colorize, anime, ghibli, watercolormaps = pipe.dense_predict(photo) # {"seg", "depth", "normal"}```### transformers```pythonfrom transformers import AutoModelmodel = AutoModel.from_pretrained("DmitrofNET/Teveration-1", trust_remote_code=True)images = model.text_to_image(["A lighthouse on a rocky cliff under a stormy sky."], seed=0) # uint8 [B, 512, 512, 3]images = model.image_to_image(photos, task="colorize")maps = model.dense_predict(photos)```### Python, without either```bashpip install git+https://github.com/DmitrofNETDev/Teveration-1python -m teveration t2i "A lighthouse on a rocky cliff under a stormy sky." --seed 0``````pythonfrom teveration import Teverationtev = Teveration() # device="auto" | "cuda" | "vulkan" | "cpu", quality="small" | "balanced" | "high"images = tev.text_to_image(["An oil painting of sunflowers in a blue ceramic vase."], seed=0)```### ComfyUIFour nodes (loader, text to image, image to image, dense prediction):[comfyui/](https://github.com/DmitrofNETDev/Teveration-1/tree/main/comfyui).### Command line and serverEngine archives are on the [GitHub release](https://github.com/DmitrofNETDev/Teveration-1/releases).```bashhf download DmitrofNET/Teveration-1 --include "*.gguf" --local-dir modelsteveration t2i --model models --prompt "A lighthouse on a rocky cliff under a stormy sky."teveration serve --model models --port 8188 # OpenAI images API and the AUTOMATIC1111 txt2img call```## Where it runs| | Status ||---|---|| NVIDIA GPUs (CUDA 12), Windows and Linux | measured on an RTX 4070, every feature || CPU only | measured on Windows; the Linux and macOS builds run a self-test in CI || AMD and Intel GPUs (Vulkan) | built in CI and self-tested there on a software Vulkan driver. Not yet run on an AMD card || Apple Silicon (Metal) | built in CI, not yet run on a Mac GPU |## EvaluationMeasured from these files on an RTX 4070 with1 unmodified linesame requests with the same random states and sampling draws; each number compares Teveration's output with theoriginal's output for the same request.| | Jeveration (original) | small | **balanced** | high ||---|---|---|---|---|| Download and disk size | 19.08 GB | 2.59 GB | **2.79 GB** | 3.08 GB || GPU memory in use, every feature loaded | 11.4 GB (generator alone) | 4.8 GB | **4.7 GB** | 4.7 GB || Text-to-image, CLIP text score (32 pictures) | 0.321 | 0.316 | **0.323** | 0.322 || Text-to-image, similarity to the original's picture (worst case) | 1 | 0.961 (0.892) | **0.965 (0.851)** | 0.969 (0.920) || Image-to-image, similarity to the original's picture (worst case), 8 pictures | 1 | 0.973 (0.928) | **0.969 (0.934)** | 0.968 (0.943) || Segmentation, pixels agreeing with the original (4 rooms) | 100% | 96.1% | **96.6%** | 97.1% || Depth, difference from the original | 0% | 3.7% | **2.4%** | 2.0% || Surface normals, difference from the original | 0° | 8.8° | **7.7°** | 6.5° || One 512 px picture, RTX 4070 | | 0.18 s | **0.18 s** | 0.17 s |Balanced also: load 5 s, image-to-image 0.30 s, dense prediction 0.92 s, process RAM 2.3 GB;text-to-image only needs 4.0 GB of GPU memory. On the CPU alone: 9 s per picture, 4.2 GB of RAM.The pictures match their prompts as well as the original's do, but they are not the same pictures: compositions andcolours shift. This is a small-sample fidelity check against the original. GenEval, DPG-Bench, HPS and NYUv29 unmodified lines1. Dead weight removed (4.3 GB): one of the two decoder files is a bit-identical subset of the other, CLIP's vision toweris never used, and only the codebook of the 1.6 GB tokenizer is used.2. The frozen Qwen3.5-4B backbone (9.3 GB) is replaced by PrismML's ternary version of the same model (0.95 GB), withQwen's own norm gains and linear-attention state tensors put back.3. Jeveration's LoRA cannot be merged and rounded: its update is 2.5 to 4.8 times larger than the base weights. Eachmatrix instead keeps a separate low-rank path, `W = T + U A`, re-fitted in closed form so that it carries both the LoRAand what ternarization removed, weighted by the inputs the matrix sees on calibration prompts. No gradient step. It isstored as a standard llama.cpp LoRA adapter.4. The head and the CLIP text tower are rounded to 4 bits, the vision tower and the decoder to 8 bits. Each choice isthe lowest precision that component tolerated when rounded on its own.5. A C++ engine on PrismML's llama.cpp fork runs the result without unpacking it to float weights.The full analysis and every measurement:[docs/analysis.md](https://github.com/DmitrofNETDev/Teveration-1/blob/main/docs/analysis.md). The files in detail:[docs/FORMAT.md](https://github.com/DmitrofNETDev/Teveration-1/blob/main/docs/FORMAT.md).## Limits- GPU memory is about 4.7 GB, more than the files: on a GPU the low-rank path is held in half precision, because thequantized kernels of the CUDA backend did not give repeatable results on these matrices. On the CPU nothing is unpacked.- On CUDA, about one run in a thousand differs from a repeat of itself at rounding level. The CPU path is bit-exact.- Outputs drift from the original's; dense maps differ by a few percent. No public benchmark has been run yet.- AMD, Intel and Apple GPUs are built and self-tested in CI but not measured on hardware.- No training was done. A distilled successor at about 1.5 GB is planned.- Inherits Jeveration's limits: 512 px output, English prompts, 13 indoor classes for segmentation.6 unmodified linesTeveration 1 is a derivative of [Jeveration](https://huggingface.co/linlinlinlinsdada/Jeveration) (The JeverationAuthors), [Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Alibaba Cloud),[Ternary Bonsai 2 4B](https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-gguf) (created using Bonsai by Prism ML),[TA-TiTok](https://huggingface.co/turkeyju/tokenizer_tatitok_bl128_vq) (Bytedance) and CLIP ViT-L/14-336 (OpenAI), allunder Apache 2.0. Their notices are in `NOTICE` and `THIRD_PARTY_NOTICES.md`; what was changed is listed in`LICENSE-WEIGHTS.md`.```bibtex@software{teveration1,title = {Teveration 1: a ternary-backbone GGUF build of the Jeveration image model},author = {DmitrofNET},year = {2026},url = {https://github.com/DmitrofNETDev/Teveration-1}
6 unmodified lines7891011121310 unmodified lines2425262728293031323334353610 unmodified lines474849505152532 unmodified lines565758596061626 unmodified lines- Paper: "Jeveration: System One Models Now Generate", https://arxiv.org/abs/2611.24738- Code: https://github.com/Carol-lyh/Jeveration, commit `cf74be36efe522bdf49adc3326fe233190731812`. Its inference packageis included unmodified in `teveration/third_party/Jeveration/`, with its own `LICENSE`, `NOTICE` and`THIRD_PARTY_NOTICES.md` (which cover the TA-TiTok file it vendors).- Weights: https://huggingface.co/linlinlinlinsdada/Jeveration (`jeveration.pt`, `source_decoder512.pt`), licenseapache-2.0. Copyright 2026 The Jeveration Authors.10 unmodified lines## Qwen3.5-4B- https://huggingface.co/Qwen/Qwen3.5-4B, revision `851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a`. Copyright 2026 Alibaba Cloud.- Used: the small full-precision tensors of the language model, the vision tower, the tokenizer and configuration files(`model/qwen/`), and the full weights as the reference the low-rank path is fitted to.## Ternary Bonsai 2 4B- https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-mlx-2bit. Copyright 2026-present Prism ML, Inc.- Used: the ternary matrices, their scales and sign patterns, and the ternary token embedding.Upstream NOTICE:10 unmodified lines- https://github.com/bytedance/1d-tokenizer; tokenizer weights https://huggingface.co/turkeyju/tokenizer_tatitok_bl128_vq,revision `7650d466a955c754265d20e57513518a4e049f00`. Copyright 2024 Bytedance Ltd. and/or its affiliates.- Used: the VQ-128 codebook and `config.json`. Jeveration's decoders are fine-tuned from this tokenizer's decoder.## CLIP ViT-L/14-3362 unmodified lines- Used: the text tower, as the text input of the decoder. The benchmark also uses the full model as a judge; it is notpart of the released files.## Python packagesPyTorch, Transformers, Accelerate, open_clip, OmegaConf, einops, NumPy, Pillow and safetensors are installed separatelyunder their own licenses.6 unmodified lines7891011121310 unmodified lines24252627282930313233343536373810 unmodified lines495051525354552 unmodified lines58596061626364656667686970717273746 unmodified lines- Paper: "Jeveration: System One Models Now Generate", https://arxiv.org/abs/2611.24738- Code: https://github.com/Carol-lyh/Jeveration, commit `cf74be36efe522bdf49adc3326fe233190731812`. Its inference packageis included unmodified in `third_party/Jeveration/` (the benchmark runs the original model with it), with its own `LICENSE`, `NOTICE` and`THIRD_PARTY_NOTICES.md` (which cover the TA-TiTok file it vendors).- Weights: https://huggingface.co/linlinlinlinsdada/Jeveration (`jeveration.pt`, `source_decoder512.pt`), licenseapache-2.0. Copyright 2026 The Jeveration Authors.10 unmodified lines## Qwen3.5-4B- https://huggingface.co/Qwen/Qwen3.5-4B, revision `851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a`. Copyright 2026 Alibaba Cloud.- Used: the small full-precision tensors of the language model, and the full weights as the reference the low-rankpath is fitted to.## Ternary Bonsai 2 4B- https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-gguf and https://huggingface.co/prism-ml/Ternary-Bonsai-2-4B-mlx-2bit.Copyright 2026-present Prism ML, Inc.- Used: the ternary matrices, their scales and sign patterns, the ternary token embedding and the tokenizer(`Ternary-Bonsai-2-4B-PTQ1_0.gguf`), and the vision tower (`Ternary-Bonsai-2-4B-mmproj-Q8_0.gguf`).Upstream NOTICE:10 unmodified lines- https://github.com/bytedance/1d-tokenizer; tokenizer weights https://huggingface.co/turkeyju/tokenizer_tatitok_bl128_vq,revision `7650d466a955c754265d20e57513518a4e049f00`. Copyright 2024 Bytedance Ltd. and/or its affiliates.- Used: the VQ-128 codebook. Jeveration's decoders are fine-tuned from this tokenizer's decoder.## CLIP ViT-L/14-3362 unmodified lines- Used: the text tower, as the text input of the decoder. The benchmark also uses the full model as a judge; it is notpart of the released files.## llama.cpp (PrismML fork)- https://github.com/PrismML-Eng/llama.cpp, commit `43f31f400c66dd44ce52a044119db77c271fed06`, MIT license. Copyright (c)2023-2026 The ggml authors; the fork's additions (ternary tensor types, Hadamard-rotated weights, Qwen3.5) are by Prism ML.- The engine in `cpp/` links it statically and applies the changes in `cpp/patches/`. The engine archives of a releasetherefore contain it, together with the libraries it vendors: cpp-httplib (MIT), nlohmann/json (MIT) and stb (MIT orpublic domain). Their license texts are in that repository.- The CUDA archives for Windows come with NVIDIA's CUDA runtime libraries in a separate archive, redistributed under theNVIDIA CUDA Toolkit end user license agreement.## Python packagesThe binding needs NumPy and Pillow. The export scripts and the benchmark also use PyTorch, Transformers, Accelerate,open_clip, OmegaConf, einops, safetensors and gguf. All are installed separately under their own licenses.
123version https://git-lfs.github.com/spec/v1oid sha256:05451cb5eafa4a575d2d907149fa634cbccd06b0032677d492a4911374e60e1dsize 502946808123version https://git-lfs.github.com/spec/v1oid sha256:8794bdb5d3e6cf2b2f090ce9b3dec78281ee73488731570fa104fc0261a5b5a2size 548563968
123version https://git-lfs.github.com/spec/v1oid sha256:97a8e3eda7ce9a2af2856ee55e9f31b81cc042aa813e02bee217f201e9735914size 915827176123version https://git-lfs.github.com/spec/v1oid sha256:b76c727c29773d59f1ebb963ce72d72b8fafbc62658fcfcdcb5150cad97b9a63size 746744832
123version https://git-lfs.github.com/spec/v1oid sha256:b57f8099813f63ffd8ab144ecdb15b815a94882cbd6f3651945ce3163fb48a1fsize 1036151808123version https://git-lfs.github.com/spec/v1oid sha256:7c22a2c5d6b83d1562af939adee42436685e01802e5bed291ff78514417a2956size 395764290123version https://git-lfs.github.com/spec/v1oid sha256:e723957cbd25803c796dd115f2b5adc54f87b59302d8b5fabc12bac24f1c4120size 949550112
123version https://git-lfs.github.com/spec/v1oid sha256:9af4d1a7f6a87358d62b633f8688e76fc801572e1831c3ed5c8b9e857da3ff26size 430860000123version https://git-lfs.github.com/spec/v1oid sha256:5818516141df5311c3a29a433b54835f596bfbff4d494bd47a551ee8910a4efcsize 723575968
123version https://git-lfs.github.com/spec/v1oid sha256:db939d5f9b7014137810205e91d05e5f54afd72b0b3af9d33bd7d82f7906a55dsize 3668946242 unmodified lines34567891049 unmodified lines606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731745 unmodified lines1801811821831841851861871881891901911921931941951961971981992002012022 unmodified lines"t2i_images": 32,"i2i_images": 8,"dense_images": 4,"gpu": "NVIDIA GeForce RTX 4070","torch": "2.7.1+cu126"},"quality": {"Jeveration (original)": {49 unmodified lines"depth_rel_diff": 0.0,"normal_angle_deg": 0.007803942426107824},"Teveration 1": {"t2i_images": 32,"t2i_clip_text": 0.32199835777282715,"t2i_clip_to_ref": 0.963968813419342,"t2i_clip_to_ref_min": 0.887638509273529,"t2i_psnr_to_ref": 15.503606832589254,"t2i_code_kl": 1.0689625999997423,"t2i_same_codes": 0.1494140625,"i2i_images": 8,"i2i_clip_to_ref": 0.9727672338485718,"i2i_clip_to_ref_min": 0.9449974894523621,"i2i_psnr_to_ref": 17.552984944194037,"i2i_per_task": {"hed:hed_puppy": [0.974,15.4],"hed:hed_tulips": [0.984,19.1],"depth:depth_pancakes": [0.992,11.8],"colorize:gray_burger": [0.945,22.2],"colorize:gray_pancakes": [0.99,23.0],"anime:photo_boathouse": [0.96,16.4],"ghibli:photo_pine": [0.963,15.9],"watercolor:photo_snowcabin": [0.974,16.6]},"i2i_code_kl": 4.073315920747981,"i2i_same_codes": 0.14453125,"dense_images": 4,"seg_agreement": 0.9502179175615311,"depth_rel_diff": 0.0355030014179647,"normal_angle_deg": 11.246941566467285},"original codes, Teveration decoders": {"t2i_images": 32,"t2i_clip_text": 0.3220173120498657,"t2i_clip_to_ref": 0.9990553855895996,"t2i_clip_to_ref_min": 0.9961732029914856,"t2i_psnr_to_ref": 41.303918786389296,"i2i_images": 8,"i2i_clip_to_ref": 0.999341607093811,"i2i_clip_to_ref_min": 0.9990346431732178,"i2i_psnr_to_ref": 45.54683479052196,"i2i_per_task": {"hed:hed_puppy": [0.999,44.6],"hed:hed_tulips": [0.999,47.2],"depth:depth_pancakes": [1.0,41.4],"colorize:gray_burger": [0.999,47.6],"colorize:gray_pancakes": [0.999,49.2],"anime:photo_boathouse": [0.999,44.8],"ghibli:photo_pine": [0.999,46.7],"watercolor:photo_snowcabin": [0.999,43.0]}}},"system": {"Jeveration (original)": {"load_s": 54.25053644180298,"s_per_forward": 0.5139813423156738,"vram_peak_gb": 11.432709632},"Teveration 1": {"load_s": 10.881783485412598,"s_per_forward": 0.46289029717445374,"vram_peak_gb": 11.167675392}},"sizes": {5 unmodified lines"CLIP ViT-L/14-336": 1711828444,"TA-TiTok VQ-128": 1564268440},"teveration": {"adapter.safetensors": 502946808,"backbone.safetensors": 915827176,"codec.safetensors": 395764290,"head.safetensors": 430860000,"vision.safetensors": 369819984,"qwen/chat_template.jinja": 7756,"qwen/config.json": 3161,"qwen/merges.txt": 3353259,"qwen/preprocessor_config.json": 390,"qwen/tokenizer.json": 12807982,"qwen/tokenizer_config.json": 16710,"qwen/video_preprocessor_config.json": 385,"qwen/vocab.json": 6722759,"tatitok/config.json": 745},"original_total": 19076329536,"teveration_total": 2638131405}}2 unmodified lines345678949 unmodified lines59606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323335 unmodified lines3393403413423433443453463473483493503513523533543553563572 unmodified lines"t2i_images": 32,"i2i_images": 8,"dense_images": 4,"gpu": "NVIDIA GeForce RTX 4070"},"quality": {"Jeveration (original)": {49 unmodified lines"depth_rel_diff": 0.0,"normal_angle_deg": 0.007803942426107824},"Teveration 1 small": {"t2i_images": 32,"t2i_clip_text": 0.3160281777381897,"t2i_clip_to_ref": 0.9609737396240234,"t2i_clip_to_ref_min": 0.8924240469932556,"t2i_psnr_to_ref": 15.984395477061975,"t2i_code_kl": 0.7938981110824492,"t2i_same_codes": 0.201171875,"i2i_images": 8,"i2i_clip_to_ref": 0.9730374813079834,"i2i_clip_to_ref_min": 0.9275524020195007,"i2i_psnr_to_ref": 19.813808862864438,"i2i_per_task": {"hed:hed_puppy": [0.979,17.3],"hed:hed_tulips": [0.992,20.1],"depth:depth_pancakes": [0.99,13.6],"colorize:gray_burger": [0.975,27.0],"colorize:gray_pancakes": [0.992,27.0],"anime:photo_boathouse": [0.928,17.7],"ghibli:photo_pine": [0.968,17.9],"watercolor:photo_snowcabin": [0.961,17.9]},"i2i_code_kl": 2.5608048747085608,"i2i_same_codes": 0.205078125,"dense_images": 4,"seg_agreement": 0.9607249945402145,"depth_rel_diff": 0.03694570157676935,"normal_angle_deg": 8.831704139709473},"Teveration 1 balanced": {"t2i_images": 32,"t2i_clip_text": 0.32319122552871704,"t2i_clip_to_ref": 0.9645581245422363,"t2i_clip_to_ref_min": 0.8512206077575684,"t2i_psnr_to_ref": 16.496453113360587,"t2i_code_kl": 0.5577238311309188,"t2i_same_codes": 0.260498046875,"i2i_images": 8,"i2i_clip_to_ref": 0.968909740447998,"i2i_clip_to_ref_min": 0.9335451126098633,"i2i_psnr_to_ref": 18.94284482819621,"i2i_per_task": {"hed:hed_puppy": [0.98,18.1],"hed:hed_tulips": [0.988,19.9],"depth:depth_pancakes": [0.994,12.1],"colorize:gray_burger": [0.937,22.8],"colorize:gray_pancakes": [0.974,25.5],"anime:photo_boathouse": [0.934,17.5],"ghibli:photo_pine": [0.978,17.5],"watercolor:photo_snowcabin": [0.967,18.2]},"i2i_code_kl": 1.9975855612450717,"i2i_same_codes": 0.2822265625,"dense_images": 4,"seg_agreement": 0.9657570272684097,"depth_rel_diff": 0.024094921071082354,"normal_angle_deg": 7.730892896652222},"original codes, Teveration decoder": {"t2i_images": 32,"t2i_clip_text": 0.3216998279094696,"t2i_clip_to_ref": 0.9992119073867798,"t2i_clip_to_ref_min": 0.9963964223861694,"t2i_psnr_to_ref": 42.02064534885581,"i2i_images": 8,"i2i_clip_to_ref": 0.9993463754653931,"i2i_clip_to_ref_min": 0.9990218877792358,"i2i_psnr_to_ref": 45.94756925916652,"i2i_per_task": {"hed:hed_puppy": [0.999,46.8],"hed:hed_tulips": [0.999,48.6],"depth:depth_pancakes": [0.999,41.4],"colorize:gray_burger": [0.999,48.6],"colorize:gray_pancakes": [1.0,50.0],"anime:photo_boathouse": [1.0,44.8],"ghibli:photo_pine": [1.0,46.0],"watercolor:photo_snowcabin": [0.999,41.5]}},"Teveration 1 high": {"t2i_images": 32,"t2i_clip_text": 0.32217979431152344,"t2i_clip_to_ref": 0.9692164659500122,"t2i_clip_to_ref_min": 0.920056164264679,"t2i_psnr_to_ref": 16.706373971734337,"t2i_code_kl": 0.4198659631239861,"t2i_same_codes": 0.299072265625,"i2i_images": 8,"i2i_clip_to_ref": 0.9682188034057617,"i2i_clip_to_ref_min": 0.9434037208557129,"i2i_psnr_to_ref": 20.218341491564896,"i2i_per_task": {"hed:hed_puppy": [0.966,18.2],"hed:hed_tulips": [0.986,21.7],"depth:depth_pancakes": [0.986,16.2],"colorize:gray_burger": [0.946,25.9],"colorize:gray_pancakes": [0.985,26.2],"anime:photo_boathouse": [0.943,17.3],"ghibli:photo_pine": [0.969,18.0],"watercolor:photo_snowcabin": [0.964,18.4]},"i2i_code_kl": 1.2446497647337795,"i2i_same_codes": 0.3232421875,"dense_images": 4,"seg_agreement": 0.9713632017374039,"depth_rel_diff": 0.019579092506319284,"normal_angle_deg": 6.547387957572937}},"system": {"Jeveration (original)": {"load_s": 61.69133996963501,"s_per_forward": 0.41924357414245605,"gpu_gb": 11.432709632,"note": "generator only, PyTorch, LoRA merged"},"Teveration 1 small": {"quality": "small","backend": "CUDA0","load_s": 5.777042865753174,"gpu_gb_text_to_image": 4.23828125,"s_per_image": 0.17715734243392944,"s_per_i2i": 0.3040640354156494,"s_per_dense": 0.9051661491394043,"gpu_gb": 4.7724609375,"ram_gb": 2.317299712,"threads": 6},"Teveration 1 balanced": {"quality": "balanced","backend": "CUDA0","load_s": 5.0379509925842285,"gpu_gb_text_to_image": 4.1943359375,"s_per_image": 0.1776524782180786,"s_per_i2i": 0.30004239082336426,"s_per_dense": 0.9247040748596191,"gpu_gb": 4.7265625,"ram_gb": 2.315497472,"threads": 6},"Teveration 1 high": {"quality": "high","backend": "CUDA0","load_s": 4.987344264984131,"gpu_gb_text_to_image": 4.2021484375,"s_per_image": 0.1732463240623474,"s_per_i2i": 0.29878926277160645,"s_per_dense": 0.910069465637207,"gpu_gb": 4.732421875,"ram_gb": 2.315845632,"threads": 6},"Teveration 1 balanced, text-to-image only": {"quality": "balanced","backend": "CUDA0","load_s": 4.661885499954224,"gpu_gb_text_to_image": 3.857421875,"s_per_image": 0.17474722862243652,"gpu_gb": 3.98828125,"ram_gb": 2.098991104,"threads": 6},"Teveration 1 balanced, CPU only": {"quality": "balanced","backend": "CPU","load_s": 1.8013052940368652,"gpu_gb_text_to_image": 0.2646484375,"s_per_image": 8.557481527328491,"s_per_i2i": 13.597936153411865,"s_per_dense": 16.549880504608154,"gpu_gb": 0.361328125,"ram_gb": 4.209410048,"threads": 6}},"sizes": {5 unmodified lines"CLIP ViT-L/14-336": 1711828444,"TA-TiTok VQ-128": 1564268440},"files": {"Teveration-1-backbone-PTQ1_0.gguf": 949550112,"Teveration-1-image-Q4_0.gguf": 723575968,"Teveration-1-mmproj-Q8_0.gguf": 366894624,"Teveration-1-adapter-Q4_0.gguf": 548563968,"Teveration-1-adapter-Q6_mix.gguf": 746744832,"Teveration-1-adapter-Q8_0.gguf": 1036151808},"totals": {"Teveration 1 small": 2588584672,"Teveration 1 balanced": 2786765536,"Teveration 1 high": 3076172512},"original_total": 19076329536}}
12345678910111213141516{
"model_type": "teveration",
"architectures": [
"TeverationModel"
],
"engine_device": "auto",
"quality": "balanced",
"vision": true,
"image_size": 512,
"num_codes": 128,
"codebook_size": 8192,
"auto_map": {
"AutoConfig": "modeling_teveration.TeverationConfig",
"AutoModel": "modeling_teveration.TeverationModel"
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364{
"name": "Teveration 1",
"version": "1.0",
"total_bytes": 2638131405,
"rank": 512,
"files": {
"adapter.safetensors": {
"bytes": 502946808,
"sha256": "05451cb5eafa4a575d2d907149fa634cbccd06b0032677d492a4911374e60e1d"
},
"backbone.safetensors": {
"bytes": 915827176,
"sha256": "97a8e3eda7ce9a2af2856ee55e9f31b81cc042aa813e02bee217f201e9735914"
},
"codec.safetensors": {
"bytes": 395764290,
"sha256": "7c22a2c5d6b83d1562af939adee42436685e01802e5bed291ff78514417a2956"
},
"head.safetensors": {
"bytes": 430860000,
"sha256": "9af4d1a7f6a87358d62b633f8688e76fc801572e1831c3ed5c8b9e857da3ff26"
},
"vision.safetensors": {
"bytes": 369819984,
"sha256": "34c56d08921d079944efff1708412f5e28ce4e965039444fd1029112042fccc1"
},
"qwen/chat_template.jinja": {
"bytes": 7756,
"sha256": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715"
},
"qwen/config.json": {
"bytes": 3161,
"sha256": "ddc63e1c717afa86c865bb5e01313d89d72bb53b97ad4a8a03ba8510c0621670"
},
"qwen/merges.txt": {
"bytes": 3353259,
"sha256": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d"
},
"qwen/preprocessor_config.json": {
"bytes": 390,
"sha256": "27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516"
},
"qwen/tokenizer.json": {
"bytes": 12807982,
"sha256": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42"
},
"qwen/tokenizer_config.json": {
"bytes": 16710,
"sha256": "316230d6a809701f4db5ea8f8fc862bc3a6f3229c937c174e674ff3ca0a64ac8"
},
"qwen/video_preprocessor_config.json": {
"bytes": 385,
"sha256": "7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13"
},
"qwen/vocab.json": {
"bytes": 6722759,
"sha256": "ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003"
},
"tatitok/config.json": {
"bytes": 745,
"sha256": "7611ddacb574d38f8da14eddc840cbf5635b19311c052117755faca8092e4c99"
}
}
}123version https://git-lfs.github.com/spec/v1oid sha256:5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42size 12807982123version https://git-lfs.github.com/spec/v1oid sha256:540088e2e3a94e295b89bf77bde761c905eb86807aa6e2193e85e3342c8c78a0size 108
1234{
"_class_name": "TeverationPipeline",
"_diffusers_version": "0.30.0"
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566"""Teveration 1 as a transformers model.
from transformers import AutoModel model = AutoModel.from_pretrained("DmitrofNET/Teveration-1", trust_remote_code=True) images = model.text_to_image(["A lighthouse on a rocky cliff under a stormy sky."], seed=0) # uint8 [B, 512, 512, 3] images = model.image_to_image(photos, task="ghibli") maps = model.dense_predict(photos) # {"seg", "depth", "normal"}
The class is a thin PreTrainedModel around the Teveration engine (GGUF, weights packed in memory); it holds no trainablePyTorch weights. The engine for this machine and the GGUF files are downloaded on first use."""import torchfrom transformers import PretrainedConfig, PreTrainedModel
try: from .teveration_engine import Teveration, local_modelexcept ImportError: from teveration.engine import Teveration, local_model
class TeverationConfig(PretrainedConfig): model_type = "teveration"
def __init__(self, engine_device="auto", quality="balanced", vision=True, image_size=512, num_codes=128, codebook_size=8192, **kwargs): super().__init__(**kwargs) self.engine_device, self.quality, self.vision = engine_device, quality, vision self.image_size, self.num_codes, self.codebook_size = image_size, num_codes, codebook_size
class TeverationModel(PreTrainedModel): config_class = TeverationConfig main_input_name = "prompts"
def __init__(self, config): super().__init__(config) self.anchor = torch.nn.Parameter(torch.zeros(1), requires_grad=False) # so that the checkpoint machinery has a tensor self._engine = None self.post_init()
def _init_weights(self, module): pass
@property def engine(self): if self._engine is None: self._engine = Teveration(model=local_model(self.config._name_or_path), device=self.config.engine_device, vision=self.config.vision, quality=self.config.quality) return self._engine
def text_to_image(self, prompts, seed=0): """prompt or list of prompts -> numpy uint8 [B, 512, 512, 3]""" return self.engine.text_to_image(prompts, seed=seed)
def image_to_image(self, images, task, captions=None, seed=0): """pictures (numpy, PIL or tensors) + task (hed, depth, colorize, anime, ghibli, watercolor) -> numpy uint8 [B, 512, 512, 3]""" return self.engine.image_to_image(images, task, captions=captions, seed=seed)
def dense_predict(self, images): """-> {"seg": class indices, "depth": meters, "normal": unit vectors}""" return self.engine.dense_predict(images)
def forward(self, prompts, seed=0): """text-to-image as a tensor: float [B, 3, 512, 512] in [0, 1]""" return torch.from_numpy(self.text_to_image(prompts, seed=seed)).permute(0, 3, 1, 2).float().div(255)
generate = text_to_image123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369"""Teveration 1 as a diffusers pipeline.
from diffusers import DiffusionPipeline pipe = DiffusionPipeline.from_pretrained("DmitrofNET/Teveration-1", custom_pipeline="DmitrofNET/Teveration-1", trust_remote_code=True) image = pipe("A lighthouse on a rocky cliff under a stormy sky.", seed=0).images[0] image = pipe(image=photo, task="ghibli").images[0] # hed, depth, colorize, anime, ghibli, watercolor maps = pipe.dense_predict(photo) # {"seg", "depth", "normal"}
The pipeline holds no PyTorch modules: the model runs in the Teveration engine (GGUF, weights packed in memory), which isdownloaded for this machine on first use. `pipe.to(...)` is accepted and ignored; choose the device with`pipe.set_device("auto" | "cuda" | "vulkan" | "cpu")` before the first call."""import numpy as npfrom diffusers import DiffusionPipelinefrom diffusers.pipelines.pipeline_utils import ImagePipelineOutput
# ---- the engine binding (teveration/engine.py of the GitHub repository) ----
import ctypesimport jsonimport osimport platformimport sysimport urllib.requestimport zipfile
import numpy as np
VERSION = "1.0.0"HF_REPO = "DmitrofNET/Teveration-1"GH_RELEASE = f"https://github.com/DmitrofNETDev/Teveration-1/releases/download/v{VERSION}/"GGUF = {"backbone": "Teveration-1-backbone-PTQ1_0.gguf", "image": "Teveration-1-image-Q4_0.gguf", "mmproj": "Teveration-1-mmproj-Q8_0.gguf"}# the low-rank path comes in three precisions; the rest of the model is the sameADAPTERS = {"small": "Teveration-1-adapter-Q4_0.gguf", "balanced": "Teveration-1-adapter-Q6_mix.gguf", "high": "Teveration-1-adapter-Q8_0.gguf"}I2I_TASKS = ("hed", "depth", "colorize", "anime", "ghibli", "watercolor")NYU13 = ("bed", "books", "ceiling", "chair", "floor", "furniture", "objects", "picture", "sofa", "table", "tv", "wall", "window")
def cache_dir(): return os.environ.get("TEVERATION_HOME") or os.path.join(os.path.expanduser("~"), ".cache", "teveration")
def _download(url, path, what): os.makedirs(os.path.dirname(path), exist_ok=True) tmp = path + ".part" have = os.path.getsize(tmp) if os.path.exists(tmp) else 0 req = urllib.request.Request(url, headers={"Range": f"bytes={have}-", "User-Agent": "teveration"} if have else {"User-Agent": "teveration"}) print(f"teveration: downloading {what}", file=sys.stderr, flush=True) with urllib.request.urlopen(req) as r, open(tmp, "ab" if have and r.status == 206 else "wb") as f: while True: chunk = r.read(1 << 22) if not chunk: break f.write(chunk) os.replace(tmp, path)
def find_model(folder=None, vision=True, quality="balanced"): """the folder that holds the GGUF files; missing files are downloaded from Hugging Face""" names = [n for k, n in list(GGUF.items()) + [("adapter", ADAPTERS[quality])] if vision or k != "mmproj"] folder = folder or os.environ.get("TEVERATION_MODEL") if folder is None: try: # the standard Hugging Face cache, shared with every other tool from huggingface_hub import hf_hub_download return os.path.dirname([hf_hub_download(HF_REPO, n) for n in names][0]) except ImportError: folder = os.path.join(cache_dir(), "model") for name in names: path = os.path.join(folder, name) if not os.path.exists(path): _download(f"https://huggingface.co/{HF_REPO}/resolve/main/{name}", path, name) return folder
def local_model(path): """path if it is a folder that already holds the GGUF files (a clone or snapshot of the repository), else None""" return path if path and os.path.isdir(path) and os.path.exists(os.path.join(path, GGUF["backbone"])) else None
def _lib_name(): return {"Windows": "libteveration.dll", "Darwin": "libteveration.dylib"}.get(platform.system(), "libteveration.so")
def _has_nvidia(): if platform.system() == "Windows": return os.path.exists(os.path.join(os.environ.get("SystemRoot", r"C:\Windows"), "System32", "nvcuda.dll")) return os.path.exists("/proc/driver/nvidia/version")
def engine_variant(device="auto"): """which prebuilt engine fits this machine: <os>-<arch>-<backend>""" system, machine = platform.system(), platform.machine().lower() arch = "arm64" if machine in ("arm64", "aarch64") else "x64" if system == "Darwin": return f"macos-{arch}-metal" name = "win" if system == "Windows" else "linux" if device == "auto": device = "cuda" if _has_nvidia() else "vulkan" return f"{name}-{arch}-{ {'cuda': 'cuda', 'vulkan': 'vulkan', 'cpu': 'cpu'}[device] }"
def find_library(device="auto"): """libteveration: $TEVERATION_LIB, next to this package (teveration/bin), the cache, or the release of this version""" env = os.environ.get("TEVERATION_LIB") if env: return env here = os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin", _lib_name()) if os.path.exists(here): return here variant = engine_variant(device) folder = os.path.join(cache_dir(), "engine", f"{VERSION}-{variant}") path = os.path.join(folder, _lib_name()) if not os.path.exists(path): archive = os.path.join(folder, "engine.zip") _download(f"{GH_RELEASE}teveration-{VERSION}-{variant}.zip", archive, f"the engine ({variant})") with zipfile.ZipFile(archive) as z: z.extractall(folder) os.remove(archive) return path
def _cuda_runtime(lib): """The CUDA build needs NVIDIA's runtime libraries (cudart, cublas). They are found next to the engine, in a CUDA Toolkit, or in a PyTorch / nvidia-* pip install; on Windows, when they are nowhere, the release's copy is fetched.""" folder = os.path.dirname(os.path.abspath(lib)) if platform.system() == "Windows": if any(os.path.exists(os.path.join(d, "cublas64_12.dll")) for d in _dll_dirs(lib)): return if os.path.dirname(folder).startswith(os.path.join(cache_dir(), "engine")) or folder.startswith(os.path.join(cache_dir(), "engine")): archive = os.path.join(folder, "cudart.zip") _download(GH_RELEASE + "cudart-win-x64-cuda12.zip", archive, "the CUDA runtime libraries") with zipfile.ZipFile(archive) as z: z.extractall(folder) os.remove(archive) elif platform.system() == "Linux": for p in sys.path: # pip's nvidia-cublas-cu12 / nvidia-cuda-runtime-cu12, as PyTorch installs them for sub, name in (("cuda_runtime", "libcudart.so.12"), ("cublas", "libcublasLt.so.12"), ("cublas", "libcublas.so.12")): f = os.path.join(p, "nvidia", sub, "lib", name) if os.path.exists(f): try: ctypes.CDLL(f, mode=ctypes.RTLD_GLOBAL) except OSError: pass
def _dll_dirs(lib): """Windows: where the engine's dependencies may live (its own folder, CUDA, the CUDA runtime that ships with PyTorch)""" dirs = [os.path.dirname(os.path.abspath(lib))] for var in ("CUDA_PATH",): if os.environ.get(var): dirs.append(os.path.join(os.environ[var], "bin")) for p in sys.path: d = os.path.join(p, "torch", "lib") if os.path.isdir(d): dirs.append(d) return [d for d in dirs if os.path.isdir(d)]
def _as_images(x, size=None): """a picture or a batch of pictures (numpy uint8, PIL, torch) -> list of contiguous uint8 [H, W, 3]""" if hasattr(x, "convert"): x = [x] if hasattr(x, "detach"): x = x.detach().cpu().numpy() if isinstance(x, np.ndarray) and x.ndim == 3: x = x[None] out = [] for im in x: if hasattr(im, "convert"): im = np.asarray(im.convert("RGB")) im = np.asarray(im) if im.dtype != np.uint8: im = (np.clip(im.astype(np.float32), 0, 1) * 255).round().astype(np.uint8) out.append(np.ascontiguousarray(im[..., :3])) return out
class Teveration: def __init__(self, model=None, device="auto", threads=0, vision=True, quality="balanced", lib=None): """model: folder with the GGUF files (default: download to the cache); device: auto, cuda, vulkan or cpu; vision: load the vision tower too (needed for image_to_image and dense_predict, about 0.4 GB); quality: small (2.6 GB in total), balanced (2.8 GB) or high (3.1 GB): the precision of the low-rank path""" assert quality in ADAPTERS, f"quality must be one of {tuple(ADAPTERS)}" self.folder = find_model(model, vision, quality) self.quality = quality self.lib = L = self._open(lib, device) c, u8p, i32p, f32p = ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint8), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_float) L.tev_load.restype = ctypes.c_void_p L.tev_load.argtypes = [c, c, c, c, ctypes.c_int, ctypes.c_int] L.tev_free.argtypes = [ctypes.c_void_p] for name in ("tev_last_error", "tev_version"): getattr(L, name).restype = c for name in ("tev_backend", "tev_dense_classes"): getattr(L, name).restype = c getattr(L, name).argtypes = [ctypes.c_void_p] L.tev_text_to_image_ex.argtypes = [ctypes.c_void_p, c, ctypes.c_uint64, f32p, ctypes.c_int, f32p, u8p, i32p, f32p] L.tev_image_to_image_ex.argtypes = [ctypes.c_void_p, u8p, ctypes.c_int, ctypes.c_int, c, c, ctypes.c_uint64, f32p, ctypes.c_int, f32p, u8p, i32p, f32p] L.tev_dense_predict.argtypes = [ctypes.c_void_p, u8p, ctypes.c_int, ctypes.c_int, u8p, f32p, f32p] L.tev_decode.argtypes = [ctypes.c_void_p, i32p, c, u8p] L.tev_decode_source.argtypes = [ctypes.c_void_p, i32p, u8p, c, c, u8p] p = lambda key: os.path.join(self.folder, ADAPTERS[quality] if key == "adapter" else GGUF[key]).encode() # noqa: E731 self.h = L.tev_load(p("backbone"), p("adapter"), p("image"), p("mmproj") if vision else None, 0 if device == "cpu" else 1, int(threads)) if not self.h: raise RuntimeError("teveration: " + L.tev_last_error().decode(errors="replace")) self.backend = L.tev_backend(self.h).decode() self.vision = vision
def _open(self, lib, device): """load the engine library; with device="auto" a backend whose runtime is missing falls back to the next one""" fixed = lib or os.environ.get("TEVERATION_LIB") order = [device] if (fixed or device != "auto" or platform.system() == "Darwin") else (["cuda"] if _has_nvidia() else []) + ["vulkan", "cpu"] last = None for d in order: try: path = fixed or find_library(d) if "cuda" in engine_variant(d) or fixed: _cuda_runtime(path) if platform.system() == "Windows": self._dirs = [os.add_dll_directory(x) for x in _dll_dirs(path)] return ctypes.CDLL(path) except OSError as err: # also urllib's errors: the archive of this backend is not there last = err print(f"teveration: the {d} engine could not be loaded ({err}); trying the next backend", file=sys.stderr) raise RuntimeError(f"teveration: no engine could be loaded: {last}")
def close(self): if getattr(self, "h", None): self.lib.tev_free(self.h) self.h = None
def __del__(self): try: self.close() except Exception: # noqa: BLE001 pass
def _check(self, rc): if rc != 0: raise RuntimeError("teveration: " + self.lib.tev_last_error().decode(errors="replace"))
@staticmethod def _ptr(a, t): return None if a is None else a.ctypes.data_as(ctypes.POINTER(t))
# ---- tasks ---------------------------------------------------------------------------------------------------------------- def text_to_image(self, prompts, seed=0, state=None, k_masked=0, u=None, return_codes=False, return_logits=False, decode=True): """prompt or list of prompts -> uint8 [B, 512, 512, 3]; picture i uses seed + i. state [B, 128, 64], k_masked [B], u [B, 128]: the random draws from outside (evaluation).""" prompts = [prompts] if isinstance(prompts, str) else list(prompts) n = len(prompts) images = np.zeros((n, 512, 512, 3), np.uint8) codes = np.zeros((n, 128), np.int32) logits = np.zeros((n, 128, 8192), np.float32) if return_logits else None for i, prompt in enumerate(prompts): st = None if state is None else np.ascontiguousarray(state[i], np.float32) uu = None if u is None else np.ascontiguousarray(u[i], np.float32) self._check(self.lib.tev_text_to_image_ex( self.h, prompt.encode(), int(seed) + i, self._ptr(st, ctypes.c_float), int(np.atleast_1d(k_masked)[i if np.ndim(k_masked) else 0]), self._ptr(uu, ctypes.c_float), self._ptr(images[i], ctypes.c_uint8) if decode else None, self._ptr(codes[i], ctypes.c_int32), self._ptr(logits[i], ctypes.c_float) if return_logits else None)) out = (images,) + ((codes,) if return_codes else ()) + ((logits,) if return_logits else ()) return out[0] if len(out) == 1 else out
def image_to_image(self, sources, task, captions=None, seed=0, state=None, k_masked=0, u=None, return_codes=False, return_logits=False, decode=True): """pictures of any size (resized and centre-cropped to 512) -> uint8 [B, 512, 512, 3]; captions for hed / depth""" assert task in I2I_TASKS, f"task must be one of {I2I_TASKS}" sources = _as_images(sources) n = len(sources) captions = [captions] * n if isinstance(captions, str) else (list(captions) if captions is not None else [""] * n) images = np.zeros((n, 512, 512, 3), np.uint8) codes = np.zeros((n, 128), np.int32) logits = np.zeros((n, 128, 8192), np.float32) if return_logits else None for i, src in enumerate(sources): st = None if state is None else np.ascontiguousarray(state[i], np.float32) uu = None if u is None else np.ascontiguousarray(u[i], np.float32) self._check(self.lib.tev_image_to_image_ex( self.h, self._ptr(src, ctypes.c_uint8), src.shape[1], src.shape[0], task.encode(), captions[i].encode(), int(seed) + i, self._ptr(st, ctypes.c_float), int(np.atleast_1d(k_masked)[i if np.ndim(k_masked) else 0]), self._ptr(uu, ctypes.c_float), self._ptr(images[i], ctypes.c_uint8) if decode else None, self._ptr(codes[i], ctypes.c_int32), self._ptr(logits[i], ctypes.c_float) if return_logits else None)) out = (images,) + ((codes,) if return_codes else ()) + ((logits,) if return_logits else ()) return out[0] if len(out) == 1 else out
def dense_predict(self, pictures): """pictures of one size [B, H, W, 3] -> {"seg": class indices uint8 [B, H, W] (see NYU13), "depth": meters float32 [B, H, W], "normal": unit vectors float32 [B, H, W, 3]}""" pictures = _as_images(pictures) segs, depths, normals = [], [], [] for pic in pictures: h, w = pic.shape[:2] seg, depth, normal = np.zeros((h, w), np.uint8), np.zeros((h, w), np.float32), np.zeros((h, w, 3), np.float32) self._check(self.lib.tev_dense_predict(self.h, self._ptr(pic, ctypes.c_uint8), w, h, self._ptr(seg, ctypes.c_uint8), self._ptr(depth, ctypes.c_float), self._ptr(normal, ctypes.c_float))) segs.append(seg) depths.append(depth) normals.append(normal) return {"seg": np.stack(segs), "depth": np.stack(depths), "normal": np.stack(normals)}
def decode(self, codes, texts, sources=None, task=None, captions=None): """the decoder half: codes [B, 128] + the texts the decoder reads -> uint8 [B, 512, 512, 3]; with sources (512 x 512, grey for colorize) and a task it is the image-to-image decoder""" codes = np.ascontiguousarray(codes, np.int32) images = np.zeros((len(codes), 512, 512, 3), np.uint8) for i in range(len(codes)): if sources is None: self._check(self.lib.tev_decode(self.h, self._ptr(codes[i], ctypes.c_int32), texts[i].encode(), self._ptr(images[i], ctypes.c_uint8))) else: src = np.ascontiguousarray(sources[i], np.uint8) self._check(self.lib.tev_decode_source(self.h, self._ptr(codes[i], ctypes.c_int32), self._ptr(src, ctypes.c_uint8), task.encode(), (captions[i] if captions else "").encode(), self._ptr(images[i], ctypes.c_uint8))) return images
def info(): return json.dumps({"version": VERSION, "engine": engine_variant(), "cache": cache_dir(), "files": GGUF, "adapters": ADAPTERS}, indent=1)
class TeverationPipeline(DiffusionPipeline): def __init__(self): super().__init__() self._engine, self._device, self._model_dir, self._quality = None, "auto", None, "balanced"
def set_device(self, device="auto", model_dir=None, quality="balanced"): """device: auto, cuda, vulkan or cpu; quality: small, balanced or high (which adapter file)""" self._device, self._model_dir, self._quality = device, model_dir, quality if self._engine is not None: self._engine.close() self._engine = None return self
@property def engine(self): if self._engine is None: folder = self._model_dir or local_model(getattr(self.config, "_name_or_path", None)) self._engine = Teveration(model=folder, device=self._device, quality=self._quality) return self._engine
def to(self, *args, **kwargs): # nothing lives in PyTorch return self
def __call__(self, prompt=None, image=None, task=None, num_images_per_prompt=1, seed=None, generator=None, output_type="pil", return_dict=True, **unused): """text-to-image: prompt (str or list). image-to-image: image + task (+ prompt as the caption for hed / depth). seed: int; or generator: a torch.Generator whose state gives the seed. output_type: "pil" or "np".""" if seed is None: if generator is not None: import torch seed = int(torch.randint(0, 2 ** 31 - 1, (1,), generator=generator).item()) else: seed = int(np.random.randint(0, 2 ** 31 - 1)) if image is not None: assert task is not None, "image-to-image needs task= (hed, depth, colorize, anime, ghibli, watercolor)" caption = prompt if isinstance(prompt, str) else (prompt[0] if prompt else "") images = self.engine.image_to_image(image, task, captions=caption or "", seed=seed) else: prompts = [prompt] if isinstance(prompt, str) else list(prompt) images = self.engine.text_to_image([p for p in prompts for _ in range(num_images_per_prompt)], seed=seed) if output_type == "pil": images = self.numpy_to_pil(images.astype(np.float32) / 255.0) elif output_type != "np": raise ValueError("output_type must be 'pil' or 'np'") else: images = images.astype(np.float32) / 255.0 return ImagePipelineOutput(images=images) if return_dict else (images,)
def dense_predict(self, image): """segmentation (13 indoor classes), depth in meters and surface normals of one or more pictures""" return self.engine.dense_predict(image)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154{%- set image_count = namespace(value=0) %}{%- set video_count = namespace(value=0) %}{%- macro render_content(content, do_vision_count, is_system_content=false) %} {%- if content is string %} {{- content }} {%- elif content is iterable and content is not mapping %} {%- for item in content %} {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} {%- if is_system_content %} {{- raise_exception('System message cannot contain images.') }} {%- endif %} {%- if do_vision_count %} {%- set image_count.value = image_count.value + 1 %} {%- endif %} {%- if add_vision_id %} {{- 'Picture ' ~ image_count.value ~ ': ' }} {%- endif %} {{- '<|vision_start|><|image_pad|><|vision_end|>' }} {%- elif 'video' in item or item.type == 'video' %} {%- if is_system_content %} {{- raise_exception('System message cannot contain videos.') }} {%- endif %} {%- if do_vision_count %} {%- set video_count.value = video_count.value + 1 %} {%- endif %} {%- if add_vision_id %} {{- 'Video ' ~ video_count.value ~ ': ' }} {%- endif %} {{- '<|vision_start|><|video_pad|><|vision_end|>' }} {%- elif 'text' in item %} {{- item.text }} {%- else %} {{- raise_exception('Unexpected item type in content.') }} {%- endif %} {%- endfor %} {%- elif content is none or content is undefined %} {{- '' }} {%- else %} {{- raise_exception('Unexpected content type.') }} {%- endif %}{%- endmacro %}{%- if not messages %} {{- raise_exception('No messages provided.') }}{%- endif %}{%- if tools and tools is iterable and tools is not mapping %} {{- '<|im_start|>system\n' }} {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }} {%- for tool in tools %} {{- "\n" }} {{- tool | tojson }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content, false, true)|trim %} {%- if content %} {{- '\n\n' + content }} {%- endif %} {%- endif %} {{- '<|im_end|>\n' }}{%- else %} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content, false, true)|trim %} {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}{%- for message in messages[::-1] %} {%- set index = (messages|length - 1) - loop.index0 %} {%- if ns.multi_step_tool and message.role == "user" %} {%- set content = render_content(message.content, false)|trim %} {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %} {%- set ns.multi_step_tool = false %} {%- set ns.last_query_index = index %} {%- endif %} {%- endif %}{%- endfor %}{%- if ns.multi_step_tool %} {{- raise_exception('No user query found in messages.') }}{%- endif %}{%- for message in messages %} {%- set content = render_content(message.content, true)|trim %} {%- if message.role == "system" %} {%- if not loop.first %} {{- raise_exception('System message must be at the beginning.') }} {%- endif %} {%- elif message.role == "user" %} {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} {%- elif message.role == "assistant" %} {%- set reasoning_content = '' %} {%- if message.reasoning_content is string %} {%- set reasoning_content = message.reasoning_content %} {%- else %} {%- if '</think>' in content %} {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %} {%- set content = content.split('</think>')[-1].lstrip('\n') %} {%- endif %} {%- endif %} {%- set reasoning_content = reasoning_content|trim %} {%- if loop.index0 > ns.last_query_index %} {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }} {%- else %} {{- '<|im_start|>' + message.role + '\n' + content }} {%- endif %} {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {%- if loop.first %} {%- if content|trim %} {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- else %} {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- else %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|im_end|>\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user' }} {%- endif %} {{- '\n<tool_response>\n' }} {{- content }} {{- '\n</tool_response>' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- raise_exception('Unexpected message role.') }} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- if enable_thinking is defined and enable_thinking is false %} {{- '<think>\n\n</think>\n\n' }} {%- else %} {{- '<think>\n' }} {%- endif %}{%- endif %}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104{ "architectures": [ "Qwen3_5ForConditionalGeneration" ], "image_token_id": 248056, "model_type": "qwen3_5", "text_config": { "attention_bias": false, "attention_dropout": 0.0, "attn_output_gate": true, "dtype": "bfloat16", "eos_token_id": 248044, "full_attention_interval": 4, "head_dim": 256, "hidden_act": "silu", "hidden_size": 2560, "initializer_range": 0.02, "intermediate_size": 9216, "layer_types": [ "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention" ], "linear_conv_kernel_dim": 4, "linear_key_head_dim": 128, "linear_num_key_heads": 16, "linear_num_value_heads": 32, "linear_value_head_dim": 128, "max_position_embeddings": 262144, "mlp_only_layers": [], "model_type": "qwen3_5_text", "mtp_num_hidden_layers": 1, "mtp_use_dedicated_embeddings": false, "num_attention_heads": 16, "num_hidden_layers": 32, "num_key_value_heads": 4, "rms_norm_eps": 1e-06, "tie_word_embeddings": true, "use_cache": true, "vocab_size": 248320, "mamba_ssm_dtype": "float32", "rope_parameters": { "mrope_interleaved": true, "mrope_section": [ 11, 11, 10 ], "rope_type": "default", "rope_theta": 10000000, "partial_rotary_factor": 0.25 } }, "tie_word_embeddings": true, "transformers_version": "4.57.0.dev0", "video_token_id": 248057, "vision_config": { "deepstack_visual_indexes": [], "depth": 24, "hidden_act": "gelu_pytorch_tanh", "hidden_size": 1024, "in_channels": 3, "initializer_range": 0.02, "intermediate_size": 4096, "model_type": "qwen3_5", "num_heads": 16, "num_position_embeddings": 2304, "out_hidden_size": 2560, "patch_size": 16, "spatial_merge_size": 2, "temporal_patch_size": 2 }, "vision_end_token_id": 248054, "vision_start_token_id": 248053}123456789101112131415161718192021{ "size": { "longest_edge": 16777216, "shortest_edge": 65536 }, "patch_size": 16, "temporal_patch_size": 2, "merge_size": 2, "image_mean": [ 0.5, 0.5, 0.5 ], "image_std": [ 0.5, 0.5, 0.5 ], "processor_class": "Qwen3VLProcessor", "image_processor_type": "Qwen2VLImageProcessorFast"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305{ "add_prefix_space": false, "added_tokens_decoder": { "248044": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248045": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248046": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248047": { "content": "<|object_ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248048": { "content": "<|object_ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248049": { "content": "<|box_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248050": { "content": "<|box_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248051": { "content": "<|quad_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248052": { "content": "<|quad_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248053": { "content": "<|vision_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248054": { "content": "<|vision_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248055": { "content": "<|vision_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248056": { "content": "<|image_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248057": { "content": "<|video_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248058": { "content": "<tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248059": { "content": "</tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248060": { "content": "<|fim_prefix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248061": { "content": "<|fim_middle|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248062": { "content": "<|fim_suffix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248063": { "content": "<|fim_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248064": { "content": "<|repo_name|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248065": { "content": "<|file_sep|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248066": { "content": "<tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248067": { "content": "</tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248068": { "content": "<think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248069": { "content": "</think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "248070": { "content": "<|audio_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248071": { "content": "<|audio_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248072": { "content": "<tts_pad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248073": { "content": "<tts_text_bos>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248074": { "content": "<tts_text_eod>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248075": { "content": "<tts_text_bos_single>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "248076": { "content": "<|audio_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>" ], "bos_token": null, "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}", "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "model_max_length": 262144, "pad_token": "<|endoftext|>", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null, "add_bos_token": false, "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+", "extra_special_tokens": { "audio_bos_token": "<|audio_start|>", "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "image_token": "<|image_pad|>", "video_token": "<|video_pad|>", "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>" }}123456789101112131415161718192021{ "size": { "longest_edge": 25165824, "shortest_edge": 4096 }, "patch_size": 16, "temporal_patch_size": 2, "merge_size": 2, "image_mean": [ 0.5, 0.5, 0.5 ], "image_std": [ 0.5, 0.5, 0.5 ], "processor_class": "Qwen3VLProcessor", "video_processor_type": "Qwen3VLVideoProcessor"}12345678910111213141516171819202122232425262728{ "experiment": { "tokenizer_checkpoint": "tatitok_bl128_vq.bin", "output_dir": "tatitok_bl128_vq" }, "model": { "vq_model": { "quantize_mode": "vq", "codebook_size": 8192, "token_size": 64, "use_l2_norm": false, "commitment_cost": 0.25, "clustering_vq": true, "vit_enc_model_size": "base", "vit_dec_model_size": "large", "vit_enc_patch_size": 16, "vit_dec_patch_size": 16, "num_latent_tokens": 128, "finetune_decoder": false, "is_legacy": false } }, "dataset": { "preprocessing": { "crop_size": 256 } }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308"""Teveration 1 in Python: a thin binding of the C++ engine (libteveration), which runs the GGUF files.
from teveration import Teveration tev = Teveration() # downloads the model and the engine on first use images = tev.text_to_image(["A lighthouse on a rocky cliff under a stormy sky."], seed=0) # uint8 [B, 512, 512, 3] images = tev.image_to_image(pictures, "colorize") # tasks: hed, depth, colorize, anime, ghibli, watercolor maps = tev.dense_predict(pictures) # {"seg", "depth", "normal"}
The weights stay packed in memory (ternary backbone, 4-bit adapter and head), so the model needs about its file size inRAM or VRAM, on any GPU the engine has a backend for (CUDA, Vulkan, Metal) or on the CPU."""import ctypesimport jsonimport osimport platformimport sysimport urllib.requestimport zipfile
import numpy as np
VERSION = "1.0.0"HF_REPO = "DmitrofNET/Teveration-1"GH_RELEASE = f"https://github.com/DmitrofNETDev/Teveration-1/releases/download/v{VERSION}/"GGUF = {"backbone": "Teveration-1-backbone-PTQ1_0.gguf", "image": "Teveration-1-image-Q4_0.gguf", "mmproj": "Teveration-1-mmproj-Q8_0.gguf"}# the low-rank path comes in three precisions; the rest of the model is the sameADAPTERS = {"small": "Teveration-1-adapter-Q4_0.gguf", "balanced": "Teveration-1-adapter-Q6_mix.gguf", "high": "Teveration-1-adapter-Q8_0.gguf"}I2I_TASKS = ("hed", "depth", "colorize", "anime", "ghibli", "watercolor")NYU13 = ("bed", "books", "ceiling", "chair", "floor", "furniture", "objects", "picture", "sofa", "table", "tv", "wall", "window")
def cache_dir(): return os.environ.get("TEVERATION_HOME") or os.path.join(os.path.expanduser("~"), ".cache", "teveration")
def _download(url, path, what): os.makedirs(os.path.dirname(path), exist_ok=True) tmp = path + ".part" have = os.path.getsize(tmp) if os.path.exists(tmp) else 0 req = urllib.request.Request(url, headers={"Range": f"bytes={have}-", "User-Agent": "teveration"} if have else {"User-Agent": "teveration"}) print(f"teveration: downloading {what}", file=sys.stderr, flush=True) with urllib.request.urlopen(req) as r, open(tmp, "ab" if have and r.status == 206 else "wb") as f: while True: chunk = r.read(1 << 22) if not chunk: break f.write(chunk) os.replace(tmp, path)
def find_model(folder=None, vision=True, quality="balanced"): """the folder that holds the GGUF files; missing files are downloaded from Hugging Face""" names = [n for k, n in list(GGUF.items()) + [("adapter", ADAPTERS[quality])] if vision or k != "mmproj"] folder = folder or os.environ.get("TEVERATION_MODEL") if folder is None: try: # the standard Hugging Face cache, shared with every other tool from huggingface_hub import hf_hub_download return os.path.dirname([hf_hub_download(HF_REPO, n) for n in names][0]) except ImportError: folder = os.path.join(cache_dir(), "model") for name in names: path = os.path.join(folder, name) if not os.path.exists(path): _download(f"https://huggingface.co/{HF_REPO}/resolve/main/{name}", path, name) return folder
def local_model(path): """path if it is a folder that already holds the GGUF files (a clone or snapshot of the repository), else None""" return path if path and os.path.isdir(path) and os.path.exists(os.path.join(path, GGUF["backbone"])) else None
def _lib_name(): return {"Windows": "libteveration.dll", "Darwin": "libteveration.dylib"}.get(platform.system(), "libteveration.so")
def _has_nvidia(): if platform.system() == "Windows": return os.path.exists(os.path.join(os.environ.get("SystemRoot", r"C:\Windows"), "System32", "nvcuda.dll")) return os.path.exists("/proc/driver/nvidia/version")
def engine_variant(device="auto"): """which prebuilt engine fits this machine: <os>-<arch>-<backend>""" system, machine = platform.system(), platform.machine().lower() arch = "arm64" if machine in ("arm64", "aarch64") else "x64" if system == "Darwin": return f"macos-{arch}-metal" name = "win" if system == "Windows" else "linux" if device == "auto": device = "cuda" if _has_nvidia() else "vulkan" return f"{name}-{arch}-{ {'cuda': 'cuda', 'vulkan': 'vulkan', 'cpu': 'cpu'}[device] }"
def find_library(device="auto"): """libteveration: $TEVERATION_LIB, next to this package (teveration/bin), the cache, or the release of this version""" env = os.environ.get("TEVERATION_LIB") if env: return env here = os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin", _lib_name()) if os.path.exists(here): return here variant = engine_variant(device) folder = os.path.join(cache_dir(), "engine", f"{VERSION}-{variant}") path = os.path.join(folder, _lib_name()) if not os.path.exists(path): archive = os.path.join(folder, "engine.zip") _download(f"{GH_RELEASE}teveration-{VERSION}-{variant}.zip", archive, f"the engine ({variant})") with zipfile.ZipFile(archive) as z: z.extractall(folder) os.remove(archive) return path
def _cuda_runtime(lib): """The CUDA build needs NVIDIA's runtime libraries (cudart, cublas). They are found next to the engine, in a CUDA Toolkit, or in a PyTorch / nvidia-* pip install; on Windows, when they are nowhere, the release's copy is fetched.""" folder = os.path.dirname(os.path.abspath(lib)) if platform.system() == "Windows": if any(os.path.exists(os.path.join(d, "cublas64_12.dll")) for d in _dll_dirs(lib)): return if os.path.dirname(folder).startswith(os.path.join(cache_dir(), "engine")) or folder.startswith(os.path.join(cache_dir(), "engine")): archive = os.path.join(folder, "cudart.zip") _download(GH_RELEASE + "cudart-win-x64-cuda12.zip", archive, "the CUDA runtime libraries") with zipfile.ZipFile(archive) as z: z.extractall(folder) os.remove(archive) elif platform.system() == "Linux": for p in sys.path: # pip's nvidia-cublas-cu12 / nvidia-cuda-runtime-cu12, as PyTorch installs them for sub, name in (("cuda_runtime", "libcudart.so.12"), ("cublas", "libcublasLt.so.12"), ("cublas", "libcublas.so.12")): f = os.path.join(p, "nvidia", sub, "lib", name) if os.path.exists(f): try: ctypes.CDLL(f, mode=ctypes.RTLD_GLOBAL) except OSError: pass
def _dll_dirs(lib): """Windows: where the engine's dependencies may live (its own folder, CUDA, the CUDA runtime that ships with PyTorch)""" dirs = [os.path.dirname(os.path.abspath(lib))] for var in ("CUDA_PATH",): if os.environ.get(var): dirs.append(os.path.join(os.environ[var], "bin")) for p in sys.path: d = os.path.join(p, "torch", "lib") if os.path.isdir(d): dirs.append(d) return [d for d in dirs if os.path.isdir(d)]
def _as_images(x, size=None): """a picture or a batch of pictures (numpy uint8, PIL, torch) -> list of contiguous uint8 [H, W, 3]""" if hasattr(x, "convert"): x = [x] if hasattr(x, "detach"): x = x.detach().cpu().numpy() if isinstance(x, np.ndarray) and x.ndim == 3: x = x[None] out = [] for im in x: if hasattr(im, "convert"): im = np.asarray(im.convert("RGB")) im = np.asarray(im) if im.dtype != np.uint8: im = (np.clip(im.astype(np.float32), 0, 1) * 255).round().astype(np.uint8) out.append(np.ascontiguousarray(im[..., :3])) return out
class Teveration: def __init__(self, model=None, device="auto", threads=0, vision=True, quality="balanced", lib=None): """model: folder with the GGUF files (default: download to the cache); device: auto, cuda, vulkan or cpu; vision: load the vision tower too (needed for image_to_image and dense_predict, about 0.4 GB); quality: small (2.6 GB in total), balanced (2.8 GB) or high (3.1 GB): the precision of the low-rank path""" assert quality in ADAPTERS, f"quality must be one of {tuple(ADAPTERS)}" self.folder = find_model(model, vision, quality) self.quality = quality self.lib = L = self._open(lib, device) c, u8p, i32p, f32p = ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint8), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_float) L.tev_load.restype = ctypes.c_void_p L.tev_load.argtypes = [c, c, c, c, ctypes.c_int, ctypes.c_int] L.tev_free.argtypes = [ctypes.c_void_p] for name in ("tev_last_error", "tev_version"): getattr(L, name).restype = c for name in ("tev_backend", "tev_dense_classes"): getattr(L, name).restype = c getattr(L, name).argtypes = [ctypes.c_void_p] L.tev_text_to_image_ex.argtypes = [ctypes.c_void_p, c, ctypes.c_uint64, f32p, ctypes.c_int, f32p, u8p, i32p, f32p] L.tev_image_to_image_ex.argtypes = [ctypes.c_void_p, u8p, ctypes.c_int, ctypes.c_int, c, c, ctypes.c_uint64, f32p, ctypes.c_int, f32p, u8p, i32p, f32p] L.tev_dense_predict.argtypes = [ctypes.c_void_p, u8p, ctypes.c_int, ctypes.c_int, u8p, f32p, f32p] L.tev_decode.argtypes = [ctypes.c_void_p, i32p, c, u8p] L.tev_decode_source.argtypes = [ctypes.c_void_p, i32p, u8p, c, c, u8p] p = lambda key: os.path.join(self.folder, ADAPTERS[quality] if key == "adapter" else GGUF[key]).encode() # noqa: E731 self.h = L.tev_load(p("backbone"), p("adapter"), p("image"), p("mmproj") if vision else None, 0 if device == "cpu" else 1, int(threads)) if not self.h: raise RuntimeError("teveration: " + L.tev_last_error().decode(errors="replace")) self.backend = L.tev_backend(self.h).decode() self.vision = vision
def _open(self, lib, device): """load the engine library; with device="auto" a backend whose runtime is missing falls back to the next one""" fixed = lib or os.environ.get("TEVERATION_LIB") order = [device] if (fixed or device != "auto" or platform.system() == "Darwin") else (["cuda"] if _has_nvidia() else []) + ["vulkan", "cpu"] last = None for d in order: try: path = fixed or find_library(d) if "cuda" in engine_variant(d) or fixed: _cuda_runtime(path) if platform.system() == "Windows": self._dirs = [os.add_dll_directory(x) for x in _dll_dirs(path)] return ctypes.CDLL(path) except OSError as err: # also urllib's errors: the archive of this backend is not there last = err print(f"teveration: the {d} engine could not be loaded ({err}); trying the next backend", file=sys.stderr) raise RuntimeError(f"teveration: no engine could be loaded: {last}")
def close(self): if getattr(self, "h", None): self.lib.tev_free(self.h) self.h = None
def __del__(self): try: self.close() except Exception: # noqa: BLE001 pass
def _check(self, rc): if rc != 0: raise RuntimeError("teveration: " + self.lib.tev_last_error().decode(errors="replace"))
@staticmethod def _ptr(a, t): return None if a is None else a.ctypes.data_as(ctypes.POINTER(t))
# ---- tasks ---------------------------------------------------------------------------------------------------------------- def text_to_image(self, prompts, seed=0, state=None, k_masked=0, u=None, return_codes=False, return_logits=False, decode=True): """prompt or list of prompts -> uint8 [B, 512, 512, 3]; picture i uses seed + i. state [B, 128, 64], k_masked [B], u [B, 128]: the random draws from outside (evaluation).""" prompts = [prompts] if isinstance(prompts, str) else list(prompts) n = len(prompts) images = np.zeros((n, 512, 512, 3), np.uint8) codes = np.zeros((n, 128), np.int32) logits = np.zeros((n, 128, 8192), np.float32) if return_logits else None for i, prompt in enumerate(prompts): st = None if state is None else np.ascontiguousarray(state[i], np.float32) uu = None if u is None else np.ascontiguousarray(u[i], np.float32) self._check(self.lib.tev_text_to_image_ex( self.h, prompt.encode(), int(seed) + i, self._ptr(st, ctypes.c_float), int(np.atleast_1d(k_masked)[i if np.ndim(k_masked) else 0]), self._ptr(uu, ctypes.c_float), self._ptr(images[i], ctypes.c_uint8) if decode else None, self._ptr(codes[i], ctypes.c_int32), self._ptr(logits[i], ctypes.c_float) if return_logits else None)) out = (images,) + ((codes,) if return_codes else ()) + ((logits,) if return_logits else ()) return out[0] if len(out) == 1 else out
def image_to_image(self, sources, task, captions=None, seed=0, state=None, k_masked=0, u=None, return_codes=False, return_logits=False, decode=True): """pictures of any size (resized and centre-cropped to 512) -> uint8 [B, 512, 512, 3]; captions for hed / depth""" assert task in I2I_TASKS, f"task must be one of {I2I_TASKS}" sources = _as_images(sources) n = len(sources) captions = [captions] * n if isinstance(captions, str) else (list(captions) if captions is not None else [""] * n) images = np.zeros((n, 512, 512, 3), np.uint8) codes = np.zeros((n, 128), np.int32) logits = np.zeros((n, 128, 8192), np.float32) if return_logits else None for i, src in enumerate(sources): st = None if state is None else np.ascontiguousarray(state[i], np.float32) uu = None if u is None else np.ascontiguousarray(u[i], np.float32) self._check(self.lib.tev_image_to_image_ex( self.h, self._ptr(src, ctypes.c_uint8), src.shape[1], src.shape[0], task.encode(), captions[i].encode(), int(seed) + i, self._ptr(st, ctypes.c_float), int(np.atleast_1d(k_masked)[i if np.ndim(k_masked) else 0]), self._ptr(uu, ctypes.c_float), self._ptr(images[i], ctypes.c_uint8) if decode else None, self._ptr(codes[i], ctypes.c_int32), self._ptr(logits[i], ctypes.c_float) if return_logits else None)) out = (images,) + ((codes,) if return_codes else ()) + ((logits,) if return_logits else ()) return out[0] if len(out) == 1 else out
def dense_predict(self, pictures): """pictures of one size [B, H, W, 3] -> {"seg": class indices uint8 [B, H, W] (see NYU13), "depth": meters float32 [B, H, W], "normal": unit vectors float32 [B, H, W, 3]}""" pictures = _as_images(pictures) segs, depths, normals = [], [], [] for pic in pictures: h, w = pic.shape[:2] seg, depth, normal = np.zeros((h, w), np.uint8), np.zeros((h, w), np.float32), np.zeros((h, w, 3), np.float32) self._check(self.lib.tev_dense_predict(self.h, self._ptr(pic, ctypes.c_uint8), w, h, self._ptr(seg, ctypes.c_uint8), self._ptr(depth, ctypes.c_float), self._ptr(normal, ctypes.c_float))) segs.append(seg) depths.append(depth) normals.append(normal) return {"seg": np.stack(segs), "depth": np.stack(depths), "normal": np.stack(normals)}
def decode(self, codes, texts, sources=None, task=None, captions=None): """the decoder half: codes [B, 128] + the texts the decoder reads -> uint8 [B, 512, 512, 3]; with sources (512 x 512, grey for colorize) and a task it is the image-to-image decoder""" codes = np.ascontiguousarray(codes, np.int32) images = np.zeros((len(codes), 512, 512, 3), np.uint8) for i in range(len(codes)): if sources is None: self._check(self.lib.tev_decode(self.h, self._ptr(codes[i], ctypes.c_int32), texts[i].encode(), self._ptr(images[i], ctypes.c_uint8))) else: src = np.ascontiguousarray(sources[i], np.uint8) self._check(self.lib.tev_decode_source(self.h, self._ptr(codes[i], ctypes.c_int32), self._ptr(src, ctypes.c_uint8), task.encode(), (captions[i] if captions else "").encode(), self._ptr(images[i], ctypes.c_uint8))) return images
def info(): return json.dumps({"version": VERSION, "engine": engine_variant(), "cache": cache_dir(), "files": GGUF, "adapters": ADAPTERS}, indent=1)123version https://git-lfs.github.com/spec/v1oid sha256:34c56d08921d079944efff1708412f5e28ce4e965039444fd1029112042fccc1size 369819984.gitattributes+6
BENCHMARKS.md+32-39
LICENSE-WEIGHTS.md+10-11
NOTICE+4-1
README.md+108-76
THIRD_PARTY_NOTICES.md+20-8
adapter.safetensors → Teveration-1-adapter-Q4_0.ggufRenamed+2-2
backbone.safetensors → Teveration-1-adapter-Q6_mix.ggufRenamed+2-2
Teveration-1-adapter-Q8_0.ggufAdded+3
codec.safetensors → Teveration-1-backbone-PTQ1_0.ggufRenamed+2-2
head.safetensors → Teveration-1-image-Q4_0.ggufRenamed+2-2
Teveration-1-mmproj-Q8_0.ggufAdded+3
benchmark_metrics.json+229-74
config.jsonAdded+16
images/dense.jpg

Large File Pointer Details
- SHA256: 40aa45dda62cd37d8bfb4557218509633a7d7093e6616df69acb8605452b1369
- Pointer size: 131 Bytes
- Size of remote file: 236 kB

Large File Pointer Details
- SHA256: 6a8f328a55390cb110abefedb03447620b157591b82892f010f947754a3a76c5
- Pointer size: 131 Bytes
- Size of remote file: 235 kB
images/i2i.jpg

Large File Pointer Details
- SHA256: 7640e5d8edc10336a146f7ca1b9d8d51e4caad2a755b0be65bf434063a029ad5
- Pointer size: 131 Bytes
- Size of remote file: 389 kB

Large File Pointer Details
- SHA256: 9d9f7401c5f026948f563df0df829de2a27c88eaabc6b0cb5a89339bda409688
- Pointer size: 131 Bytes
- Size of remote file: 391 kB
images/t2i_1.jpg

Large File Pointer Details
- SHA256: 3f90f68c910ef4491c2bd90f26983a1696e53dc8c8d468cf39d531fe8a78e659
- Pointer size: 131 Bytes
- Size of remote file: 293 kB

Large File Pointer Details
- SHA256: 62ca257af0bf1777dc7b323f225bd54f34a8c323662a396f973fe46c9bd3a69a
- Pointer size: 131 Bytes
- Size of remote file: 289 kB
images/t2i_2.jpg

Large File Pointer Details
- SHA256: 4fb984fb54592d9044ccf6c0dcef89f5cd7c4ac1566bebcde002ee453b72be68
- Pointer size: 131 Bytes
- Size of remote file: 278 kB

Large File Pointer Details
- SHA256: a3ac25b0325719756212f8393550f0708d14d008d3d8bc78572b31c6f8cea118
- Pointer size: 131 Bytes
- Size of remote file: 286 kB
images/t2i_3.jpg

Large File Pointer Details
- SHA256: 48555a850f04224dc1dbd8979f383c7432925b83eccdc45549efb0a6d80fb461
- Pointer size: 131 Bytes
- Size of remote file: 286 kB

Large File Pointer Details
- SHA256: 6becca3e30430865a0d2a801bf2a7a531d4a8e13c09b605343e45c4840a14ccf
- Pointer size: 131 Bytes
- Size of remote file: 287 kB
images/t2i_4.jpg

Large File Pointer Details
- SHA256: 5c198c5870c07df148aac6284c5846d4da103feb9ae494da6d505c79ef63588f
- Pointer size: 131 Bytes
- Size of remote file: 279 kB

Large File Pointer Details
- SHA256: 91de82ca745dac7edd58016def96509b329c6bc41ebbba47e3c2b816d35d92be
- Pointer size: 131 Bytes
- Size of remote file: 277 kB
manifest.jsonDeleted-64
qwen/tokenizer.json → model.safetensorsRenamed+2-2
model_index.jsonAdded+4
modeling_teveration.pyAdded+66
pipeline.pyAdded+369
qwen/chat_template.jinjaDeleted-154
qwen/config.jsonDeleted-104
qwen/merges.txtDeleted
qwen/preprocessor_config.jsonDeleted-21
qwen/tokenizer_config.jsonDeleted-305
qwen/video_preprocessor_config.jsonDeleted-21
qwen/vocab.jsonDeleted
tatitok/config.jsonDeleted-28
teveration_engine.pyAdded+308
vision.safetensorsDeleted-3