Spaces:
Runtime error
Runtime error
Commit
Β·
1484b84
1
Parent(s):
da21442
- app.py +4 -0
- app/model.py +7 -4
app.py
CHANGED
@@ -3,6 +3,10 @@ import gradio as gr
|
|
3 |
from tabs.FACS_analysis import create_facs_analysis_tab
|
4 |
from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML
|
5 |
|
|
|
|
|
|
|
|
|
6 |
# Define the tab structure
|
7 |
TAB_STRUCTURE = [
|
8 |
("Visual Analysis", [
|
|
|
3 |
from tabs.FACS_analysis import create_facs_analysis_tab
|
4 |
from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML
|
5 |
|
6 |
+
# Move load_example to a global scope
|
7 |
+
def load_example():
|
8 |
+
pass # Your logic here
|
9 |
+
|
10 |
# Define the tab structure
|
11 |
TAB_STRUCTURE = [
|
12 |
("Visual Analysis", [
|
app/model.py
CHANGED
@@ -49,18 +49,21 @@ def load_models():
|
|
49 |
# Load the static ResNet50 model
|
50 |
pth_model_static = load_model(ResNet50, STATIC_MODEL_PATH)
|
51 |
|
52 |
-
# Define LSTMPyTorch parameters
|
53 |
input_size = 2048 # Example value: This should match the feature size from the ResNet50 output
|
54 |
hidden_size = 512 # Example value: Adjust based on your LSTM architecture
|
55 |
num_layers = 2 # Example value: Number of layers in the LSTM
|
56 |
num_classes = 7 # Example value: Number of emotion classes
|
57 |
|
58 |
-
# Load the dynamic LSTM model
|
59 |
-
pth_model_dynamic =
|
|
|
|
|
|
|
|
|
60 |
|
61 |
# Initialize GradCAM
|
62 |
cam = GradCAM(model=pth_model_static, target_layers=[pth_model_static.resnet.layer4])
|
63 |
|
64 |
return pth_model_static, pth_model_dynamic, cam
|
65 |
|
66 |
-
# Optionally, additional utility functions for model processing can be added here.
|
|
|
49 |
# Load the static ResNet50 model
|
50 |
pth_model_static = load_model(ResNet50, STATIC_MODEL_PATH)
|
51 |
|
52 |
+
# Define LSTMPyTorch parameters
|
53 |
input_size = 2048 # Example value: This should match the feature size from the ResNet50 output
|
54 |
hidden_size = 512 # Example value: Adjust based on your LSTM architecture
|
55 |
num_layers = 2 # Example value: Number of layers in the LSTM
|
56 |
num_classes = 7 # Example value: Number of emotion classes
|
57 |
|
58 |
+
# Load the dynamic LSTM model (if available)
|
59 |
+
pth_model_dynamic = None
|
60 |
+
if os.path.exists(DYNAMIC_MODEL_PATH):
|
61 |
+
pth_model_dynamic = load_model(LSTMPyTorch, DYNAMIC_MODEL_PATH, input_size, hidden_size, num_layers, num_classes)
|
62 |
+
else:
|
63 |
+
logger.error(f"Dynamic model file not found: {DYNAMIC_MODEL_PATH}")
|
64 |
|
65 |
# Initialize GradCAM
|
66 |
cam = GradCAM(model=pth_model_static, target_layers=[pth_model_static.resnet.layer4])
|
67 |
|
68 |
return pth_model_static, pth_model_dynamic, cam
|
69 |
|
|