Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,10 +34,20 @@ accelerator = Accelerator()
|
|
34 |
highest_label = None
|
35 |
loaded_models = {}
|
36 |
|
37 |
-
# FAISS
|
38 |
UPLOAD_DIR = "/home/user/app/uploads"
|
39 |
faiss_index_file = os.path.join(UPLOAD_DIR, "faiss_index.bin")
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
document_store = {}
|
42 |
|
43 |
if os.path.exists(faiss_index_file):
|
|
|
34 |
highest_label = None
|
35 |
loaded_models = {}
|
36 |
|
37 |
+
# Define upload directory and FAISS index file
|
38 |
UPLOAD_DIR = "/home/user/app/uploads"
|
39 |
faiss_index_file = os.path.join(UPLOAD_DIR, "faiss_index.bin")
|
40 |
+
|
41 |
+
# Ensure upload directory exists and has write permissions
|
42 |
+
try:
|
43 |
+
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
44 |
+
if not os.access(UPLOAD_DIR, os.W_OK):
|
45 |
+
print(f"Fixing permissions for {UPLOAD_DIR}...")
|
46 |
+
os.chmod(UPLOAD_DIR, 0o777)
|
47 |
+
print(f"Uploads directory is ready: {UPLOAD_DIR}")
|
48 |
+
except PermissionError as e:
|
49 |
+
print(f"PermissionError: {e}. Try adjusting directory ownership or running with elevated permissions.")
|
50 |
+
|
51 |
document_store = {}
|
52 |
|
53 |
if os.path.exists(faiss_index_file):
|