Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,16 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
os.environ["TRANSFORMERS_CACHE"] = "/app/cache"
|
| 8 |
|
| 9 |
model_id = "rabiyulfahim/qa_python_gpt2"
|
| 10 |
|
| 11 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, cache_dir="/
|
| 12 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, cache_dir="/
|
|
|
|
| 13 |
|
| 14 |
app = FastAPI(title="QA GPT2 API", description="Serving HuggingFace model with FastAPI")
|
| 15 |
|
|
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# ✅ Force Hugging Face cache to /tmp (writable in Spaces)
|
| 7 |
+
os.environ["HF_HOME"] = "/tmp"
|
| 8 |
+
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
model_id = "rabiyulfahim/qa_python_gpt2"
|
| 12 |
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, cache_dir="/tmp")
|
| 14 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, cache_dir="/tmp")
|
| 15 |
+
|
| 16 |
|
| 17 |
app = FastAPI(title="QA GPT2 API", description="Serving HuggingFace model with FastAPI")
|
| 18 |
|