Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
pipe = pipeline("text2text-generation", model="google/flan-t5-small", max_new_tokens=100)
|
| 8 |
|
| 9 |
app = FastAPI()
|
|
|
|
| 1 |
+
import os
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from fastapi.responses import JSONResponse
|
| 5 |
from transformers import pipeline
|
| 6 |
|
| 7 |
+
# ✅ Set writable cache location
|
| 8 |
+
os.environ["TRANSFORMERS_CACHE"] = "/data/cache"
|
| 9 |
+
os.makedirs("/data/cache", exist_ok=True)
|
| 10 |
+
|
| 11 |
+
# ✅ Load model safely
|
| 12 |
pipe = pipeline("text2text-generation", model="google/flan-t5-small", max_new_tokens=100)
|
| 13 |
|
| 14 |
app = FastAPI()
|