Image-Text-to-Text
KerasFormers
Keras
PyTorch
JAX
TensorFlow
English
gemma3n
gemma-3n
audio-text-to-text
multimodal
Instructions to use kerasformers/gemma-3n-e2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/gemma-3n-e2b with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use kerasformers/gemma-3n-e2b with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/gemma-3n-e2b") - Notebooks
- Google Colab
- Kaggle
Standardize README to the kerasformers structure
Browse files
README.md
CHANGED
|
@@ -25,19 +25,25 @@ tags:
|
|
| 25 |
- tf
|
| 26 |
---
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
``
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
##
|
| 39 |
|
| 40 |
-
### Text
|
| 41 |
|
| 42 |
```python
|
| 43 |
import os
|
|
@@ -53,7 +59,7 @@ outputs = model.generate(**inputs, max_new_tokens=64)
|
|
| 53 |
print(tokenizer.decode(outputs[0]))
|
| 54 |
```
|
| 55 |
|
| 56 |
-
### Image +
|
| 57 |
|
| 58 |
```python
|
| 59 |
from kerasformers.models.gemma3n import Gemma3nConditionalGenerate, Gemma3nProcessor
|
|
@@ -72,6 +78,26 @@ outputs = model.generate(**inputs, max_new_tokens=64)
|
|
| 72 |
print(processor.decode(outputs[0]))
|
| 73 |
```
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
|
|
|
| 25 |
- tf
|
| 26 |
---
|
| 27 |
|
| 28 |
+
*See [our collection](https://huggingface.co/kerasformers) for all Gemma 3n sizes and variants.*
|
| 29 |
|
| 30 |
+
# Run Gemma 3n with Keras 3: JAX, PyTorch, or TensorFlow
|
| 31 |
|
| 32 |
+
[](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/gemma3n/) [](https://huggingface.co/kerasformers)
|
| 33 |
|
| 34 |
+
# kerasformers/gemma-3n-e2b
|
| 35 |
+
|
| 36 |
+
Pure-**Keras 3** conversion of [`google/gemma-3n-E2B`](https://huggingface.co/google/gemma-3n-E2B) for
|
| 37 |
+
[kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on
|
| 38 |
+
**TensorFlow / Torch / JAX**. This is a base (pretrained) checkpoint, served here as **image + audio + text -> text** via `Gemma3nConditionalGenerate`; weights are
|
| 39 |
+
stored in **bfloat16**.
|
| 40 |
+
|
| 41 |
+
For model details, license, and usage terms, see Google's
|
| 42 |
+
[model card](https://huggingface.co/google/gemma-3n-E2B).
|
| 43 |
|
| 44 |
+
## ✨ Quick start
|
| 45 |
|
| 46 |
+
### Text-only
|
| 47 |
|
| 48 |
```python
|
| 49 |
import os
|
|
|
|
| 59 |
print(tokenizer.decode(outputs[0]))
|
| 60 |
```
|
| 61 |
|
| 62 |
+
### Image + audio + text
|
| 63 |
|
| 64 |
```python
|
| 65 |
from kerasformers.models.gemma3n import Gemma3nConditionalGenerate, Gemma3nProcessor
|
|
|
|
| 78 |
print(processor.decode(outputs[0]))
|
| 79 |
```
|
| 80 |
|
| 81 |
+
Load any Gemma 3n variant the same way with `from_weights("kerasformers/<variant>")`:
|
| 82 |
+
|
| 83 |
+
| Variant | Hub |
|
| 84 |
+
| --- | --- |
|
| 85 |
+
| `gemma-3n-e2b` | [kerasformers/gemma-3n-e2b](https://huggingface.co/kerasformers/gemma-3n-e2b) |
|
| 86 |
+
| `gemma-3n-e2b-it` | [kerasformers/gemma-3n-e2b-it](https://huggingface.co/kerasformers/gemma-3n-e2b-it) |
|
| 87 |
+
| `gemma-3n-e4b` | [kerasformers/gemma-3n-e4b](https://huggingface.co/kerasformers/gemma-3n-e4b) |
|
| 88 |
+
| `gemma-3n-e4b-it` | [kerasformers/gemma-3n-e4b-it](https://huggingface.co/kerasformers/gemma-3n-e4b-it) |
|
| 89 |
+
|
| 90 |
+
## Tips
|
| 91 |
+
|
| 92 |
+
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
|
| 93 |
+
- Loads in **bfloat16** by default. Pass `load_dtype="float32"` for full precision,
|
| 94 |
+
or `quantization="int8"` to shrink further.
|
| 95 |
+
- See the [Gemma 3n docs](https://imvision12.github.io/KerasFormers/gemma3n/).
|
| 96 |
+
- Community / upstream weights still work via the `hf:` prefix:
|
| 97 |
+
`Gemma3nConditionalGenerate.from_weights("hf:google/gemma-3n-E2B")`.
|
| 98 |
+
|
| 99 |
+
## Special Thanks
|
| 100 |
+
|
| 101 |
+
A huge thank you to the Google Gemma authors for creating and releasing these models.
|
| 102 |
|
| 103 |
+
License: Gemma (gated). Accept the license on the upstream Hub card before downloading.
|