Spaces:
Runtime error
Runtime error
Factor Studios
commited on
Update vision_analyzer.py
Browse files- vision_analyzer.py +24 -14
vision_analyzer.py
CHANGED
|
@@ -60,23 +60,33 @@ def log_message(message: str):
|
|
| 60 |
|
| 61 |
|
| 62 |
# Initialize rarfile with correct paths
|
|
|
|
|
|
|
| 63 |
import rarfile
|
| 64 |
-
rarfile.UNRAR_TOOL = "unrar" # Try system unrar if exists
|
| 65 |
-
|
| 66 |
-
# Set alternative paths where unrar might be installed
|
| 67 |
-
possible_unrar_paths = [
|
| 68 |
-
"/usr/bin/unrar",
|
| 69 |
-
"/usr/local/bin/unrar",
|
| 70 |
-
"/bin/unrar",
|
| 71 |
-
"/app/bin/unrar"
|
| 72 |
-
]
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
else:
|
| 79 |
-
|
|
|
|
|
|
|
| 80 |
|
| 81 |
# Attempt to install flash-attn
|
| 82 |
try:
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
# Initialize rarfile with correct paths
|
| 63 |
+
import os
|
| 64 |
+
import shutil
|
| 65 |
import rarfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
# Try to detect unrar
|
| 68 |
+
unrar_path = shutil.which("unrar")
|
| 69 |
+
|
| 70 |
+
# Fallback to common paths
|
| 71 |
+
if not unrar_path:
|
| 72 |
+
possible_unrar_paths = [
|
| 73 |
+
"/usr/bin/unrar",
|
| 74 |
+
"/usr/local/bin/unrar",
|
| 75 |
+
"/bin/unrar",
|
| 76 |
+
"/app/bin/unrar"
|
| 77 |
+
]
|
| 78 |
+
for path in possible_unrar_paths:
|
| 79 |
+
if os.path.isfile(path) and os.access(path, os.X_OK):
|
| 80 |
+
unrar_path = path
|
| 81 |
+
break
|
| 82 |
+
|
| 83 |
+
# Assign to rarfile
|
| 84 |
+
if unrar_path:
|
| 85 |
+
rarfile.UNRAR_TOOL = unrar_path
|
| 86 |
else:
|
| 87 |
+
rarfile.UNRAR_TOOL = None # Use built-in (limited) parser
|
| 88 |
+
print("⚠️ 'unrar' is not installed. Some RAR files may not extract properly.")
|
| 89 |
+
|
| 90 |
|
| 91 |
# Attempt to install flash-attn
|
| 92 |
try:
|