File size: 3,492 Bytes
63b82ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
pipeline_tag: image-text-to-text
license: mit
base_model: deepseek-ai/Janus-Pro-7B
library_name: kerasformers
tags:
- keras
- kerasformers
- janus
- janus-pro
- vision-language
- image-text-to-text
- arxiv:2501.17811
- pytorch
- jax
- tf
---

## ***See [our collection](https://huggingface.co/collections/kerasformers/janus-pro-6a6eb583a6ae12da1d14c227) for all versions of Janus-Pro.***

# Run Janus-Pro with Keras 3: JAX, PyTorch, or TensorFlow

[![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-Janus--Pro-blue)](https://imvision12.github.io/KerasFormers/janus/) [![Collection](https://img.shields.io/badge/HF-Janus--Pro%20collection-yellow)](https://huggingface.co/collections/kerasformers/janus-pro-6a6eb583a6ae12da1d14c227)

# kerasformers/janus_pro_7b

Paper: [Janus-Pro: Unified Multimodal Understanding and Generation with Data and Model Scaling (arXiv:2501.17811)](https://arxiv.org/abs/2501.17811) · [HF Papers](https://huggingface.co/papers/2501.17811)

Janus-Pro is a multimodal model (SigLIP tower + GELU aligner + Llama decoder). This KerasFormers port covers the **understanding** path only (image + text → text). Multi-image conversations are supported; VQ image generation is not ported.

For more details on the model, please go to the upstream [model card](https://huggingface.co/deepseek-ai/Janus-Pro-7B).

Pure-**Keras 3** conversion of [`deepseek-ai/Janus-Pro-7B`](https://huggingface.co/deepseek-ai/Janus-Pro-7B) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.

This is a **vision-language** checkpoint (`JanusConditionalGenerate`, 7B).

## ✨ Quick start

```python
import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from PIL import Image
from kerasformers.models.janus import JanusConditionalGenerate, JanusProcessor

model = JanusConditionalGenerate.from_weights("kerasformers/janus_pro_7b")
processor = JanusProcessor.from_weights("kerasformers/janus_pro_7b")

image = Image.open("your_image.jpg")
inputs = processor(
    conversation=[
        {
            "role": "user",
            "content": [
                {"type": "image", "image": image},
                {"type": "text", "text": "Describe this image in one sentence."},
            ],
        }
    ]
)
outputs = model.generate(**inputs, max_new_tokens=64)
print(processor.decode(outputs[0]))
```

Load any Janus-Pro variant the same way with `from_weights("kerasformers/<variant>")`:

| Variant | Hub |
|---|---|
| `janus_pro_1b` | [`kerasformers/janus_pro_1b`](https://huggingface.co/kerasformers/janus_pro_1b) |
| `janus_pro_7b` | [`kerasformers/janus_pro_7b`](https://huggingface.co/kerasformers/janus_pro_7b) |

## Tips

- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
- Prefer `JanusProcessor.from_weights(...)` so image size and tokenizer match.
- Add multiple `{"type": "image", ...}` items for multi-image chats.
- See [Janus-Pro docs](https://imvision12.github.io/KerasFormers/janus/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `JanusConditionalGenerate.from_weights("hf:deepseek-ai/Janus-Pro-7B")`.

## Special Thanks

A huge thank you to the DeepSeek Janus-Pro authors for creating and releasing these models.

License: MIT.