Spaces:
Runtime error
Runtime error
Commit
Β·
5f09150
1
Parent(s):
fd37619
app.py
CHANGED
@@ -2,8 +2,12 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from tabs.FACS_analysis import create_facs_analysis_tab
|
4 |
from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML
|
5 |
-
import spaces # Importing spaces to utilize
|
6 |
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Define the tab structure
|
9 |
TAB_STRUCTURE = [
|
@@ -12,11 +16,13 @@ TAB_STRUCTURE = [
|
|
12 |
])
|
13 |
]
|
14 |
|
15 |
-
# Decorate GPU-dependent function with
|
16 |
-
@spaces.GPU(duration=
|
17 |
def create_demo():
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
21 |
gr.Markdown(HEADER_HTML)
|
22 |
with gr.Tabs(elem_classes=["main-tab"]):
|
@@ -25,9 +31,9 @@ def create_demo():
|
|
25 |
with gr.Tabs():
|
26 |
for sub_tab, create_fn in sub_tabs:
|
27 |
with gr.Tab(sub_tab):
|
28 |
-
create_fn()
|
29 |
gr.HTML(DISCLAIMER_HTML)
|
30 |
-
|
31 |
return demo
|
32 |
|
33 |
# Create the demo instance
|
|
|
2 |
import torch
|
3 |
from tabs.FACS_analysis import create_facs_analysis_tab
|
4 |
from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML
|
5 |
+
import spaces # Importing spaces to utilize GPU
|
6 |
|
7 |
+
import logging
|
8 |
+
|
9 |
+
logging.basicConfig(level=logging.INFO)
|
10 |
+
logger = logging.getLogger(__name__)
|
11 |
|
12 |
# Define the tab structure
|
13 |
TAB_STRUCTURE = [
|
|
|
16 |
])
|
17 |
]
|
18 |
|
19 |
+
# Decorate GPU-dependent function with GPU
|
20 |
+
@spaces.GPU(duration=300) # Increased duration if necessary
|
21 |
def create_demo():
|
22 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
23 |
+
logger.info(f"Using device: {device}")
|
24 |
+
|
25 |
+
# Ensure that any models loaded within create_facs_analysis_tab use the correct device
|
26 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
27 |
gr.Markdown(HEADER_HTML)
|
28 |
with gr.Tabs(elem_classes=["main-tab"]):
|
|
|
31 |
with gr.Tabs():
|
32 |
for sub_tab, create_fn in sub_tabs:
|
33 |
with gr.Tab(sub_tab):
|
34 |
+
create_fn(device=device) # Pass device if needed
|
35 |
gr.HTML(DISCLAIMER_HTML)
|
36 |
+
|
37 |
return demo
|
38 |
|
39 |
# Create the demo instance
|