Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,16 +6,15 @@ import gradio as gr
|
|
6 |
# Try import transformers; if missing the app will show a clear error message in logs.
|
7 |
try:
|
8 |
from transformers import pipeline
|
9 |
-
|
10 |
-
pipeline = None
|
11 |
-
print("transformers import error:", e)
|
12 |
|
13 |
-
|
14 |
-
MODEL_EN_TO_BN = "shhossain/opus-mt-en-to-bn"
|
15 |
-
MODEL_BN_TO_EN = "Helsinki-NLP/opus-mt-bn-en"
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
def safe_load_pipeline(model_name):
|
21 |
"""Load a translation pipeline lazily and return a tuple (success, message)."""
|
|
|
6 |
# Try import transformers; if missing the app will show a clear error message in logs.
|
7 |
try:
|
8 |
from transformers import pipeline
|
9 |
+
import os
|
|
|
|
|
10 |
|
11 |
+
auth_token = os.getenv("HF_API_TOKEN")
|
|
|
|
|
12 |
|
13 |
+
translator = pipeline(
|
14 |
+
"translation",
|
15 |
+
model="Helsinki-NLP/opus-mt-en-bn", # or your chosen model
|
16 |
+
token=auth_token
|
17 |
+
)
|
18 |
|
19 |
def safe_load_pipeline(model_name):
|
20 |
"""Load a translation pipeline lazily and return a tuple (success, message)."""
|