Text-to-Image
Transformers
PyTorch
ONNX
ezfgraphic
feature-extraction
transformer
custom_code
EZFGraphic
Instructions to use OpenRussianAI/EZFGraphic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenRussianAI/EZFGraphic with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenRussianAI/EZFGraphic", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
| 3 |
pipeline_tag: text-to-image
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
---
|
| 4 |
license: mit
|
| 5 |
+
library_name: transformers
|
| 6 |
pipeline_tag: text-to-image
|
| 7 |
+
tags: [text-to-image, transformer, custom_code, ezfgraphic]
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# EZFGraphic
|
| 11 |
+
|
| 12 |
+
Text-to-image Transformer. 128×128 from text.
|
| 13 |
+
|
| 14 |
+
## Usage
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
import torch
|
| 18 |
+
from PIL import Image
|
| 19 |
+
from transformers import AutoModel
|
| 20 |
+
from huggingface_hub import hf_hub_download
|
| 21 |
+
from tokenizers import Tokenizer
|
| 22 |
+
|
| 23 |
+
model = AutoModel.from_pretrained("OpenRussianAI/ezfgraphic", trust_remote_code=True).eval()
|
| 24 |
+
tok = Tokenizer.from_file(hf_hub_download("OpenRussianAI/ezfgraphic", "tokenizer.json"))
|
| 25 |
+
|
| 26 |
+
def generate(text, ctx=32):
|
| 27 |
+
ids = tok.encode(text).ids[:ctx]
|
| 28 |
+
ids = ids + [0] * (ctx - len(ids))
|
| 29 |
+
with torch.no_grad():
|
| 30 |
+
pixels = model(torch.tensor([ids]))
|
| 31 |
+
return (pixels[0] * 0.5 + 0.5).clamp(0, 1)
|
| 32 |
+
|
| 33 |
+
img = generate("нарисуй красный круг на тёмном фоне")
|
| 34 |
+
img_np = (img.permute(1, 2, 0).numpy() * 255).astype("uint8")
|
| 35 |
+
Image.fromarray(img_np).save("output.png")
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
MIT
|