Commit
·
e9d56b1
1
Parent(s):
edd8207
chore: add HuggingFace Spaces GPU decorator support
Browse filesAdd optional spaces import and guard; apply spaces.GPU decorator when available for GPU inference on Spaces deployments without impacting local runs.
app.py
CHANGED
|
@@ -16,6 +16,13 @@ from typing import Dict, List, Any, Optional, Tuple, Union
|
|
| 16 |
import gc
|
| 17 |
import warnings
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Suppress warnings for cleaner output
|
| 20 |
warnings.filterwarnings("ignore")
|
| 21 |
|
|
@@ -959,6 +966,10 @@ def health_check():
|
|
| 959 |
}
|
| 960 |
|
| 961 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
if __name__ == "__main__":
|
| 963 |
# Create and launch the application
|
| 964 |
try:
|
|
|
|
| 16 |
import gc
|
| 17 |
import warnings
|
| 18 |
|
| 19 |
+
# HuggingFace Spaces support
|
| 20 |
+
try:
|
| 21 |
+
import spaces
|
| 22 |
+
SPACES_AVAILABLE = True
|
| 23 |
+
except ImportError:
|
| 24 |
+
SPACES_AVAILABLE = False
|
| 25 |
+
|
| 26 |
# Suppress warnings for cleaner output
|
| 27 |
warnings.filterwarnings("ignore")
|
| 28 |
|
|
|
|
| 966 |
}
|
| 967 |
|
| 968 |
|
| 969 |
+
# Apply HuggingFace Spaces GPU decorator if available
|
| 970 |
+
if SPACES_AVAILABLE:
|
| 971 |
+
create_app = spaces.GPU(create_app)
|
| 972 |
+
|
| 973 |
if __name__ == "__main__":
|
| 974 |
# Create and launch the application
|
| 975 |
try:
|