vaibhaviiii28 commited on
Commit
038e5e9
Β·
verified Β·
1 Parent(s): 43e584e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -11,16 +11,17 @@ from flask import Flask, request, jsonify
11
  from transformers import pipeline
12
  from PIL import Image
13
 
14
- # βœ… Set Hugging Face cache directory to a writable temp path
15
  os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface_cache"
 
 
 
 
16
 
17
  # βœ… Initialize FastAPI and Flask
18
  app_fastapi = FastAPI()
19
  app_flask = Flask(__name__)
20
 
21
- # βœ… Ensure the cache directory exists (use /tmp for permission safety)
22
- os.makedirs("/tmp/huggingface_cache", exist_ok=True)
23
-
24
  # βœ… Load NSFW Image Classification Model
25
  pipe = pipeline("image-classification", model="LukeJacob2023/nsfw-image-detector")
26
 
 
11
  from transformers import pipeline
12
  from PIL import Image
13
 
14
+ # βœ… Set Hugging Face cache to a writable directory
15
  os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface_cache"
16
+ os.environ["HF_HOME"] = "/tmp/huggingface_cache"
17
+
18
+ # βœ… Ensure the cache directory exists
19
+ os.makedirs("/tmp/huggingface_cache", exist_ok=True)
20
 
21
  # βœ… Initialize FastAPI and Flask
22
  app_fastapi = FastAPI()
23
  app_flask = Flask(__name__)
24
 
 
 
 
25
  # βœ… Load NSFW Image Classification Model
26
  pipe = pipeline("image-classification", model="LukeJacob2023/nsfw-image-detector")
27