Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -106,6 +106,7 @@ tech_libraries = f"""
|
|
106 |
- transformers: {version('transformers')}
|
107 |
""".strip()
|
108 |
|
|
|
109 |
def inference(text, progress=gr.Progress()):
|
110 |
if not text:
|
111 |
raise gr.Error("Please paste your text.")
|
@@ -176,6 +177,7 @@ def inference(text, progress=gr.Progress()):
|
|
176 |
|
177 |
return "\n".join(result_texts)
|
178 |
|
|
|
179 |
if use_zero_gpu:
|
180 |
@spaces.GPU
|
181 |
def inference_gpu(text, progress=gr.Progress()):
|
@@ -184,6 +186,7 @@ if use_zero_gpu:
|
|
184 |
inference_func = inference_gpu
|
185 |
else:
|
186 |
inference_func = inference
|
|
|
187 |
|
188 |
demo = gr.Blocks(
|
189 |
title=title,
|
@@ -206,7 +209,7 @@ with demo:
|
|
206 |
text = gr.Textbox(label="Text", autofocus=True, lines=5)
|
207 |
|
208 |
gr.Button("Translate").click(
|
209 |
-
|
210 |
concurrency_limit=concurrency_limit,
|
211 |
inputs=text,
|
212 |
outputs=translated_text,
|
|
|
106 |
- transformers: {version('transformers')}
|
107 |
""".strip()
|
108 |
|
109 |
+
@spaces.GPU
|
110 |
def inference(text, progress=gr.Progress()):
|
111 |
if not text:
|
112 |
raise gr.Error("Please paste your text.")
|
|
|
177 |
|
178 |
return "\n".join(result_texts)
|
179 |
|
180 |
+
"""
|
181 |
if use_zero_gpu:
|
182 |
@spaces.GPU
|
183 |
def inference_gpu(text, progress=gr.Progress()):
|
|
|
186 |
inference_func = inference_gpu
|
187 |
else:
|
188 |
inference_func = inference
|
189 |
+
"""
|
190 |
|
191 |
demo = gr.Blocks(
|
192 |
title=title,
|
|
|
209 |
text = gr.Textbox(label="Text", autofocus=True, lines=5)
|
210 |
|
211 |
gr.Button("Translate").click(
|
212 |
+
inference,
|
213 |
concurrency_limit=concurrency_limit,
|
214 |
inputs=text,
|
215 |
outputs=translated_text,
|