rabiyulfahim commited on
Commit
fc18d76
·
verified ·
1 Parent(s): eb8a97e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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="/app/cache")
12
- model = AutoModelForCausalLM.from_pretrained(model_id, cache_dir="/app/cache")
 
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