Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +6 -1
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -8,8 +8,13 @@ from transformers import RobertaTokenizer, TFRobertaModel
|
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
import uvicorn
|
| 10 |
|
| 11 |
-
# Ensure TensorFlow uses
|
| 12 |
os.environ["TF_USE_LEGACY_KERAS"] = "1"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Initialize FastAPI app
|
| 15 |
app = FastAPI(
|
|
|
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
import uvicorn
|
| 10 |
|
| 11 |
+
# Ensure TensorFlow uses tf_keras (required for transformers compatibility)
|
| 12 |
os.environ["TF_USE_LEGACY_KERAS"] = "1"
|
| 13 |
+
# Import tf_keras to ensure it's available for transformers
|
| 14 |
+
try:
|
| 15 |
+
import tf_keras
|
| 16 |
+
except ImportError:
|
| 17 |
+
raise ImportError("tf-keras package is required. Install it with: pip install tf-keras")
|
| 18 |
|
| 19 |
# Initialize FastAPI app
|
| 20 |
app = FastAPI(
|
requirements.txt
CHANGED
|
@@ -4,7 +4,7 @@ uvicorn[standard]>=0.30.0
|
|
| 4 |
|
| 5 |
# TensorFlow and Keras for model inference
|
| 6 |
tensorflow>=2.20.0
|
| 7 |
-
keras>=
|
| 8 |
|
| 9 |
# Transformers for RoBERTa tokenizer
|
| 10 |
transformers>=4.57.3
|
|
|
|
| 4 |
|
| 5 |
# TensorFlow and Keras for model inference
|
| 6 |
tensorflow>=2.20.0
|
| 7 |
+
tf-keras>=2.20.0
|
| 8 |
|
| 9 |
# Transformers for RoBERTa tokenizer
|
| 10 |
transformers>=4.57.3
|