Spaces:
Running
on
Zero
Running
on
Zero
AndyC
commited on
Commit
·
b247971
1
Parent(s):
4c09f59
adjusted ui
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def generate_text(
|
|
47 |
input_ids = input_ids.to(model.device)
|
48 |
|
49 |
streamer = TextIteratorStreamer(
|
50 |
-
tokenizer, timeout=
|
51 |
)
|
52 |
generate_kwargs = dict(
|
53 |
{"input_ids": input_ids},
|
@@ -69,13 +69,43 @@ def generate_text(
|
|
69 |
yield " ".join(output)
|
70 |
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
demo.queue(max_size=20).launch()
|
|
|
47 |
input_ids = input_ids.to(model.device)
|
48 |
|
49 |
streamer = TextIteratorStreamer(
|
50 |
+
tokenizer, timeout=20.0, skip_prompt=True, skip_special_tokens=True
|
51 |
)
|
52 |
generate_kwargs = dict(
|
53 |
{"input_ids": input_ids},
|
|
|
69 |
yield " ".join(output)
|
70 |
|
71 |
|
72 |
+
with gr.Blocks as demo:
|
73 |
+
gr.Markdown("# Text Translation Using Google Gemma 3")
|
74 |
+
|
75 |
+
with gr.Row():
|
76 |
+
with gr.Column():
|
77 |
+
gr.Markdown("### Translate From")
|
78 |
+
from_lang = gr.Dropdown(
|
79 |
+
choices = [],
|
80 |
+
value = "auto",
|
81 |
+
label = ""
|
82 |
+
)
|
83 |
+
|
84 |
+
with gr.Column():
|
85 |
+
gr.Markdown("### Translate To")
|
86 |
+
to_lang = gr.Dropdown(
|
87 |
+
choices = [],
|
88 |
+
value = "auto",
|
89 |
+
label = ""
|
90 |
+
)
|
91 |
+
|
92 |
+
with gr.Row():
|
93 |
+
with gr.Column():
|
94 |
+
gr.Textbox(
|
95 |
+
lines = 10,
|
96 |
+
placeholder = "Enter text to translate",
|
97 |
+
label = ""
|
98 |
+
)
|
99 |
+
|
100 |
+
with gr.Column():
|
101 |
+
output_text = gr.Textbox(
|
102 |
+
lines=10,
|
103 |
+
label=""
|
104 |
+
)
|
105 |
+
|
106 |
+
translate_button = gr.Button("Translate")
|
107 |
+
|
108 |
+
|
109 |
|
110 |
if __name__ == "__main__":
|
111 |
demo.queue(max_size=20).launch()
|