EZFGraphic

An example model of EZFGraphic, Txt2Img generate

Usage

import torch
from PIL import Image
from transformers import AutoModel
from huggingface_hub import hf_hub_download
from tokenizers import Tokenizer

model = AutoModel.from_pretrained("OpenRussianAI/ezfgraphic", trust_remote_code=True).eval()
tok = Tokenizer.from_file(hf_hub_download("OpenRussianAI/ezfgraphic", "tokenizer.json"))

def generate(text, ctx=32):
    ids = tok.encode(text).ids[:ctx]
    ids = ids + [0] * (ctx - len(ids))
    with torch.no_grad():
        pixels = model(torch.tensor([ids]))
    return (pixels[0] * 0.5 + 0.5).clamp(0, 1)

img = generate("нарисуй красный круг на тёмном фоне")
img_np = (img.permute(1, 2, 0).numpy() * 255).astype("uint8")
Image.fromarray(img_np).save("output.png")

MIT

Downloads last month
77
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using OpenRussianAI/EZFGraphic 1