Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,16 @@ from fastapi import FastAPI
|
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
pipe = pipeline("translation", model="google-t5/t5-base")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
@app.get("/")
|
|
|
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
pipe = pipeline("translation", model="google-t5/t5-base")
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
# Set cache directory to a local writable directory
|
| 10 |
+
os.environ['HF_HOME'] = './cache'
|
| 11 |
+
os.environ['TRANSFORMERS_CACHE'] = './cache'
|
| 12 |
+
os.environ['TORCH_HOME'] = './cache'
|
| 13 |
+
|
| 14 |
+
# Ensure the directory exists
|
| 15 |
+
os.makedirs('./cache', exist_ok=True)
|
| 16 |
+
|
| 17 |
|
| 18 |
app = FastAPI()
|
| 19 |
@app.get("/")
|