Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def gradio_predict(input_text):
|
| 2 |
try:
|
| 3 |
# Tokenize input text
|
|
@@ -52,3 +61,12 @@ def gradio_predict(input_text):
|
|
| 52 |
import traceback
|
| 53 |
print(traceback.format_exc())
|
| 54 |
return f"Error during translation: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import onnxruntime as ort
|
| 3 |
+
from transformers import AutoTokenizer
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
MODEL_FILE = "./model.onnx"
|
| 7 |
+
session = ort.InferenceSession(MODEL_FILE)
|
| 8 |
+
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-fr")
|
| 9 |
+
|
| 10 |
def gradio_predict(input_text):
|
| 11 |
try:
|
| 12 |
# Tokenize input text
|
|
|
|
| 61 |
import traceback
|
| 62 |
print(traceback.format_exc())
|
| 63 |
return f"Error during translation: {str(e)}"
|
| 64 |
+
|
| 65 |
+
# Gradio interface for the web app
|
| 66 |
+
gr.Interface(
|
| 67 |
+
fn=gradio_predict,
|
| 68 |
+
inputs="text",
|
| 69 |
+
outputs="text",
|
| 70 |
+
live=True
|
| 71 |
+
).launch()
|
| 72 |
+
|