Spaces:
Runtime error
Runtime error
Factor Studios
commited on
Update vision_analyzer.py
Browse files- vision_analyzer.py +21 -3
vision_analyzer.py
CHANGED
|
@@ -23,10 +23,28 @@ import torch
|
|
| 23 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 24 |
# from transformers import AutoProcessor, AutoModelForCausalLM
|
| 25 |
|
| 26 |
-
# Ensure unrar is installed (for Hugging Face Spaces)
|
| 27 |
import os
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Attempt to install flash-attn
|
| 32 |
try:
|
|
|
|
| 23 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 24 |
# from transformers import AutoProcessor, AutoModelForCausalLM
|
| 25 |
|
|
|
|
| 26 |
import os
|
| 27 |
+
|
| 28 |
+
# Try to ensure unrar is available
|
| 29 |
+
def setup_unrar():
|
| 30 |
+
# Try system installation (may not work on all Spaces)
|
| 31 |
+
if not os.path.exists("/usr/bin/unrar"):
|
| 32 |
+
os.system("apt-get update > /dev/null 2>&1 && apt-get install -y unrar > /dev/null 2>&1 || true")
|
| 33 |
+
|
| 34 |
+
# Setup Python alternatives
|
| 35 |
+
try:
|
| 36 |
+
import rarfile
|
| 37 |
+
if os.path.exists("/usr/bin/unrar"):
|
| 38 |
+
rarfile.UNRAR_TOOL = "/usr/bin/unrar"
|
| 39 |
+
except ImportError:
|
| 40 |
+
os.system("pip install rarfile")
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
import patoolib
|
| 44 |
+
except ImportError:
|
| 45 |
+
os.system("pip install patool")
|
| 46 |
+
|
| 47 |
+
setup_unrar()
|
| 48 |
|
| 49 |
# Attempt to install flash-attn
|
| 50 |
try:
|