Spaces:
Sleeping
Sleeping
Alp İpekçiler
commited on
Commit
·
e62f4a7
1
Parent(s):
34c970b
Fix: Set cache directory to /tmp to resolve permission denied error
Browse files
app.py
CHANGED
|
@@ -10,6 +10,11 @@ from flask_cors import CORS
|
|
| 10 |
import logging
|
| 11 |
import os
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
app = Flask(__name__)
|
| 14 |
CORS(app, resources={r"/predict_pet": {"origins": "*"}})
|
| 15 |
|
|
@@ -126,4 +131,3 @@ def predict_pet():
|
|
| 126 |
if __name__ == '__main__':
|
| 127 |
port = int(os.environ.get('PORT', 7860))
|
| 128 |
app.run(host='0.0.0.0', port=port, debug=False)
|
| 129 |
-
|
|
|
|
| 10 |
import logging
|
| 11 |
import os
|
| 12 |
|
| 13 |
+
# Set cache directory to /tmp for Hugging Face Spaces
|
| 14 |
+
os.environ['HF_HOME'] = '/tmp/.cache'
|
| 15 |
+
os.environ['TRANSFORMERS_CACHE'] = '/tmp/.cache'
|
| 16 |
+
os.environ['TORCH_HOME'] = '/tmp/.cache'
|
| 17 |
+
|
| 18 |
app = Flask(__name__)
|
| 19 |
CORS(app, resources={r"/predict_pet": {"origins": "*"}})
|
| 20 |
|
|
|
|
| 131 |
if __name__ == '__main__':
|
| 132 |
port = int(os.environ.get('PORT', 7860))
|
| 133 |
app.run(host='0.0.0.0', port=port, debug=False)
|
|
|