Spaces:
Running on Zero
Running on Zero
Fix Gradio 6 ChatInterface: drop type=, use ChatInterface as demo
Browse files
app.py
CHANGED
|
@@ -207,62 +207,54 @@ def chat(
|
|
| 207 |
raise gr.Error(f"Generation failed: {errors[0]}")
|
| 208 |
|
| 209 |
|
| 210 |
-
CSS = """
|
| 211 |
-
#col-container { max-width: 920px; margin: 0 auto; }
|
| 212 |
-
.dark .gradio-container { color: var(--body-text-color); }
|
| 213 |
-
"""
|
| 214 |
-
|
| 215 |
DESCRIPTION = f"""
|
| 216 |
-
# Gemma 4 E2B
|
| 217 |
Chat demo for Google's edge-sized **Gemma 4** model
|
| 218 |
-
([{BASE_MODEL}](
|
| 219 |
2.3B effective parameters, 128K context, **text + image + audio**.
|
| 220 |
|
| 221 |
-
|
| 222 |
-
[`{MODEL_ID}`](https://huggingface.co/{MODEL_ID}) on ZeroGPU.
|
| 223 |
The [pretrained base](https://huggingface.co/{BASE_MODEL}) is for fine-tuning, not chat.
|
| 224 |
|
| 225 |
**Tips:** put the image *before* your question; put audio *after* it.
|
| 226 |
-
Official model card: [google/gemma-4-E2B](https://huggingface.co/google/gemma-4-E2B)
|
| 227 |
"""
|
| 228 |
|
| 229 |
EXAMPLES = [
|
| 230 |
-
{"text": "Write a short joke about saving RAM."},
|
| 231 |
-
{
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
"
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
|
|
|
| 245 |
]
|
| 246 |
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
)
|
| 266 |
|
| 267 |
if __name__ == "__main__":
|
| 268 |
demo.launch(mcp_server=True)
|
|
|
|
| 207 |
raise gr.Error(f"Generation failed: {errors[0]}")
|
| 208 |
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
DESCRIPTION = f"""
|
|
|
|
| 211 |
Chat demo for Google's edge-sized **Gemma 4** model
|
| 212 |
+
([{BASE_MODEL}](https://huggingface.co/{BASE_MODEL})):
|
| 213 |
2.3B effective parameters, 128K context, **text + image + audio**.
|
| 214 |
|
| 215 |
+
Runs the instruction-tuned checkpoint [`{MODEL_ID}`](https://huggingface.co/{MODEL_ID}) on ZeroGPU.
|
|
|
|
| 216 |
The [pretrained base](https://huggingface.co/{BASE_MODEL}) is for fine-tuning, not chat.
|
| 217 |
|
| 218 |
**Tips:** put the image *before* your question; put audio *after* it.
|
|
|
|
| 219 |
"""
|
| 220 |
|
| 221 |
EXAMPLES = [
|
| 222 |
+
[{"text": "Write a short joke about saving RAM."}, False, 512],
|
| 223 |
+
[{"text": "What is shown in this image?", "files": ["examples/golden_gate.png"]}, False, 512],
|
| 224 |
+
[
|
| 225 |
+
{
|
| 226 |
+
"text": (
|
| 227 |
+
"Transcribe the following speech segment in its original language. "
|
| 228 |
+
"Follow these specific instructions for formatting the answer:\n"
|
| 229 |
+
"* Only output the transcription, with no newlines.\n"
|
| 230 |
+
"* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, "
|
| 231 |
+
"and write 3 instead of three."
|
| 232 |
+
),
|
| 233 |
+
"files": ["examples/journal1.wav"],
|
| 234 |
+
},
|
| 235 |
+
False,
|
| 236 |
+
512,
|
| 237 |
+
],
|
| 238 |
]
|
| 239 |
|
| 240 |
+
demo = gr.ChatInterface(
|
| 241 |
+
fn=chat,
|
| 242 |
+
multimodal=True,
|
| 243 |
+
title="Gemma 4 E2B",
|
| 244 |
+
description=DESCRIPTION,
|
| 245 |
+
examples=EXAMPLES,
|
| 246 |
+
cache_examples=False,
|
| 247 |
+
additional_inputs=[
|
| 248 |
+
gr.Checkbox(label="Thinking mode", value=False),
|
| 249 |
+
gr.Slider(64, 1024, value=512, step=32, label="Max new tokens"),
|
| 250 |
+
],
|
| 251 |
+
additional_inputs_accordion="Settings",
|
| 252 |
+
textbox=gr.MultimodalTextbox(
|
| 253 |
+
file_types=["image", ".wav", ".mp3", ".flac", ".ogg", ".m4a", ".mp4", ".webm"],
|
| 254 |
+
placeholder="Ask Gemma 4 E2B — attach an image or a short audio clip…",
|
| 255 |
+
show_label=False,
|
| 256 |
+
),
|
| 257 |
+
)
|
|
|
|
| 258 |
|
| 259 |
if __name__ == "__main__":
|
| 260 |
demo.launch(mcp_server=True)
|