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.
File size: 2,964 Bytes
acea903
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""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 trainable
PyTorch weights. The engine for this machine and the GGUF files are downloaded on first use.
"""
import torch
from transformers import PretrainedConfig, PreTrainedModel

try:
    from .teveration_engine import Teveration, local_model
except 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_image