Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,8 +25,7 @@ else:
|
|
| 25 |
return func(*args, **kwargs)
|
| 26 |
return wrapper
|
| 27 |
|
| 28 |
-
|
| 29 |
-
from xformers.ops import memory_efficient_attention
|
| 30 |
# Device configuration
|
| 31 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 32 |
if device.type == "cpu":
|
|
@@ -35,6 +34,8 @@ else:
|
|
| 35 |
print("Using ZeroGPU")
|
| 36 |
torch.cuda.empty_cache()
|
| 37 |
|
|
|
|
|
|
|
| 38 |
# Load the Marigold Depth Pipeline with LCM Scheduler
|
| 39 |
try:
|
| 40 |
print("Loading depth pipeline...")
|
|
@@ -55,18 +56,21 @@ except Exception as e:
|
|
| 55 |
raise
|
| 56 |
|
| 57 |
# Enable XFormers
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
@spaces.GPU(enable_queue=True)
|
| 72 |
def predict_depth(image: Image.Image):
|
|
|
|
| 25 |
return func(*args, **kwargs)
|
| 26 |
return wrapper
|
| 27 |
|
| 28 |
+
|
|
|
|
| 29 |
# Device configuration
|
| 30 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 31 |
if device.type == "cpu":
|
|
|
|
| 34 |
print("Using ZeroGPU")
|
| 35 |
torch.cuda.empty_cache()
|
| 36 |
|
| 37 |
+
import xformers
|
| 38 |
+
from xformers.ops import memory_efficient_attention
|
| 39 |
# Load the Marigold Depth Pipeline with LCM Scheduler
|
| 40 |
try:
|
| 41 |
print("Loading depth pipeline...")
|
|
|
|
| 56 |
raise
|
| 57 |
|
| 58 |
# Enable XFormers
|
| 59 |
+
if device.type == "cuda":
|
| 60 |
+
try:
|
| 61 |
+
from xformers.ops import memory_efficient_attention
|
| 62 |
+
print("xformers is installed and operational!")
|
| 63 |
+
print("Enabling XFormers...")
|
| 64 |
+
pipe.enable_xformers_memory_efficient_attention()
|
| 65 |
+
print("XFormers enabled.")
|
| 66 |
+
except AttributeError:
|
| 67 |
+
print("XFormers is not supported in the installed version of diffusers or model.")
|
| 68 |
+
except ImportError:
|
| 69 |
+
print("XFormers library is not installed. Run `pip install xformers`.")
|
| 70 |
+
except Exception as e:
|
| 71 |
+
print(f"Unexpected error enabling XFormers: {type(e).__name__} - {e}")
|
| 72 |
+
else:
|
| 73 |
+
print("XFormers not enabled as the device is CPU.")
|
| 74 |
|
| 75 |
@spaces.GPU(enable_queue=True)
|
| 76 |
def predict_depth(image: Image.Image):
|