vaibhaviiii28 commited on
Commit
bd4bfef
·
verified ·
1 Parent(s): 0237255

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -10,11 +10,13 @@ from pydantic import BaseModel
10
  from flask import Flask, request, jsonify
11
  from transformers import pipeline
12
  from PIL import Image
 
13
 
14
  # ✅ Set Hugging Face cache to a writable directory
15
  cache_dir = "/tmp/huggingface_cache"
16
  os.environ["TRANSFORMERS_CACHE"] = cache_dir
17
  os.environ["HF_HOME"] = cache_dir
 
18
 
19
  # ✅ Ensure the cache directory exists
20
  os.makedirs(cache_dir, exist_ok=True)
 
10
  from flask import Flask, request, jsonify
11
  from transformers import pipeline
12
  from PIL import Image
13
+ import huggingface_hub
14
 
15
  # ✅ Set Hugging Face cache to a writable directory
16
  cache_dir = "/tmp/huggingface_cache"
17
  os.environ["TRANSFORMERS_CACHE"] = cache_dir
18
  os.environ["HF_HOME"] = cache_dir
19
+ huggingface_hub.utils.HF_HUB_CACHE = cache_dir # ✅ Force Hugging Face to use the correct cache directory
20
 
21
  # ✅ Ensure the cache directory exists
22
  os.makedirs(cache_dir, exist_ok=True)