reab5555 commited on
Commit
d05a31e
·
verified ·
1 Parent(s): 90fe712

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -101
app.py CHANGED
@@ -73,7 +73,6 @@ with gr.Blocks() as iface:
73
  progress_bar = gr.Progress()
74
  execution_time = gr.Number(label="Execution Time (seconds)")
75
 
76
- # Description tab outside of the results group
77
  with gr.Tabs():
78
  with gr.TabItem("Description"):
79
  with gr.Column():
@@ -91,108 +90,35 @@ with gr.Blocks() as iface:
91
  - Monitor and assess emotional states in communications.
92
  - Evaluate changes in vocal tone and speech patterns.
93
 
94
- ## Features
95
-
96
- - **Face Extraction**: Extracts faces from video frames using the MTCNN model.
97
- - **Feature Embeddings**: Extracts facial feature embeddings using the InceptionResnetV1 model.
98
- - **Body Posture Analysis**: Evaluates body postures using MediaPipe Pose.
99
- - **Voice Analysis**: Extracts and segment speaker embeddings from audio using PyAnnote.
100
- - **Anomaly Detection**: Uses Variational Autoencoder (VAE) to detect anomalies in facial expressions, body postures, and voice features over time.
101
- - **Visualization**: Represents changes in facial expressions, body postures, and vocal tone over time, marking anomaly key points.
102
-
103
- ## InceptionResnetV1
104
- The InceptionResnetV1 model is a deep convolutional neural network used for facial recognition and facial attribute extraction.
105
-
106
- - **Accuracy and Reliability**: Pre-trained on the VGGFace2 dataset, it achieves high accuracy in recognizing and differentiating between faces.
107
- - **Feature Richness**: The embeddings capture rich facial details, essential for recognizing subtle expressions and variations.
108
- - **Global Recognition**: Widely adopted in various facial recognition applications, demonstrating reliability and robustness across different scenarios.
109
-
110
- ## MediaPipe Pose
111
- MediaPipe Pose is a versatile machine learning library designed for high-accuracy real-time posture estimation. Mediapipe Pose uses a deep learning model to detect body landmarks and infer body posture.
112
-
113
- - **Real-Time Performance**: Capable of processing video frames at real-time speeds, making it suitable for live video analysis.
114
- - **Accuracy and Precision**: Detects 33 body landmarks, including important joints and key points, enabling detailed posture and movement analysis.
115
- - **Integration**: Easily integrates with other machine learning frameworks and tools, enhancing its versatility for various applications.
116
-
117
- ## Voice Analysis
118
- The voice analysis module involves extracting and analyzing vocal features using speaker diarization and embedding models to capture key characteristics of the speaker's voice.
119
-
120
- PyAnnote is a toolkit for speaker diarization and voice analysis.
121
- - **Speaker Diarization**: Identifies voice segments and classifies them by speaker.
122
- - **Speaker Embeddings**: Captures voice characteristics using a pre-trained embedding model.
123
-
124
- ## Variational Autoencoder (VAE)
125
- A Variational Autoencoder (VAE) is a type of neural network that learns to encode input data (like facial embeddings or posture scores) into a latent space and then reconstructs the data from this latent representation. VAEs not only learn to compress data but also to generate new data, making them particularly useful for anomaly detection.
126
-
127
- - **Probabilistic Nature**: VAEs introduce a probabilistic approach to encoding, where the encoded representations are not single fixed points but distributions. This allows the model to learn a more robust representation of the data.
128
- - **Reconstruction and Generation**: By comparing the reconstructed data to the original, VAEs can measure reconstruction errors. High errors indicate anomalies, as such data points do not conform well to the learned normal patterns.
129
-
130
- ## Setup Parameters
131
- - **Frames Per Second (FPS)**: Frames per second to analyze (lower for faster processing).
132
- - **Anomaly Detection Threshold**: Threshold for detecting anomalies (Standard Deviation).
133
-
134
- ## Micro-Expressions
135
- Paul Ekman's work on facial expressions of emotion identified universal micro-expressions that reveal true emotions. These fleeting expressions, lasting only milliseconds, are challenging to detect but can be captured and analyzed using computer vision algorithms when analyzing frame-by-frame.
136
-
137
- ### Micro-Expressions and Frame Rate Analysis
138
- Micro-expressions are brief, involuntary facial expressions that typically last between 1/25 to 1/5 of a second (40-200 milliseconds). To capture these fleeting expressions, a high frame rate is essential.
139
-
140
- ### 10 fps
141
-
142
- - **Frame Interval** Each frame is captured every 100 milliseconds.
143
- - **Effectiveness** Given that micro-expressions can last as short as 40 milliseconds, a frame rate of 10 fps is insufficient. Many micro-expressions would begin and end between frames, making it highly likely that they would be missed entirely.
144
-
145
- ### 20 fps
146
-
147
- - **Frame Interval** Each frame is captured every 50 milliseconds.
148
- - **Effectiveness** While 20 fps is better than 10 fps, it is still inadequate. Micro-expressions can still occur and resolve within the 50-millisecond interval between frames, leading to incomplete or missed captures.
149
-
150
- ### High-Speed Cameras
151
-
152
- Effective capture of micro-expressions generally requires frame rates above 100 fps. High-speed video systems designed for micro-expression detection often operate at 118 fps or higher, with some systems reaching up to 200 fps.
153
-
154
- ## Limitations
155
-
156
- - **Evaluation Challenges**: Since this is an unsupervised method, there is no labeled data to compare against. This makes it difficult to quantitatively evaluate the accuracy or effectiveness of the anomaly detection.
157
- - **Subjectivity**: The concept of what constitutes an "anomaly" can be subjective and context-dependent. This can lead to false positives or negatives depending on the situation.
158
- - **Lighting and Resolution**: Variability in lighting conditions, camera resolution, and frame rate can affect the quality of detected features and postures, leading to inconsistent results.
159
- - **Audio Quality**: Background noise, poor audio quality, and overlapping speech can affect the accuracy of speaker diarization and voice embeddings.
160
- - **Generalization**: The model may not generalize well to all types of videos and contexts. For example, trained embeddings may work well for a specific demographic but poorly for another.
161
- - **Computationally Intensive**: Real-time processing of high-resolution video frames can be computationally demanding, requiring significant hardware resources.
162
-
163
- ### Micro-Expressions and Frame Rate Limitations
164
- Videos recorded at 10 or 20 fps are not suitable for reliably capturing micro-expressions due to their rapid onset and brief duration. Higher frame rates, typically above 100 fps, are essential to ensure that these fleeting expressions are accurately captured and analyzed.
165
-
166
- ## Conclusion
167
- This tool offers solutions for detecting emotional, posture, and vocal anomalies in video-based facial expressions, body language, and speech, beneficial for both forensic analysis and HUMINT operations. However, users should be aware of its limitations and the challenges inherent in unsupervised anomaly detection methodologies. By leveraging advanced computer vision techniques and the power of autoencoders, it provides crucial insights into human behavior in a timely manner, but results should be interpreted with caution and, where possible, supplemented with additional context and expert analysis.
168
  """)
169
 
170
- # Results group with visible=False
171
- with gr.Group(visible=False) as results_group:
172
- with gr.Tabs():
173
- with gr.TabItem("Facial Features"):
174
- results_text = gr.TextArea(label="Faces Breakdown", lines=5)
175
- mse_features_plot = gr.Plot(label="MSE: Facial Features")
176
- mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
177
- mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
178
- anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
179
- face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
180
-
181
- with gr.TabItem("Body Posture"):
182
- mse_posture_plot = gr.Plot(label="MSE: Body Posture")
183
- mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
184
- mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
185
- anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
186
-
187
- with gr.TabItem("Voice"):
188
- mse_voice_plot = gr.Plot(label="MSE: Voice")
189
- mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
190
- mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
191
-
192
- with gr.TabItem("Combined"):
193
- heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
194
- combined_mse_plot = gr.Plot(label="Combined MSE Plot")
195
- correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
196
 
197
  df_store = gr.State()
198
  mse_features_store = gr.State()
 
73
  progress_bar = gr.Progress()
74
  execution_time = gr.Number(label="Execution Time (seconds)")
75
 
 
76
  with gr.Tabs():
77
  with gr.TabItem("Description"):
78
  with gr.Column():
 
90
  - Monitor and assess emotional states in communications.
91
  - Evaluate changes in vocal tone and speech patterns.
92
 
93
+ ... (rest of the description content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  """)
95
 
96
+ with gr.TabItem("Results", visible=False) as results_group:
97
+ with gr.Tabs():
98
+ with gr.TabItem("Facial Features"):
99
+ results_text = gr.TextArea(label="Faces Breakdown", lines=5)
100
+ mse_features_plot = gr.Plot(label="MSE: Facial Features")
101
+ mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
102
+ mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
103
+ anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
104
+ face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
105
+
106
+ with gr.TabItem("Body Posture"):
107
+ mse_posture_plot = gr.Plot(label="MSE: Body Posture")
108
+ mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
109
+ mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
110
+ anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
111
+
112
+ with gr.TabItem("Voice"):
113
+ mse_voice_plot = gr.Plot(label="MSE: Voice")
114
+ mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
115
+ mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
116
+
117
+ with gr.TabItem("Combined"):
118
+ heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
119
+ combined_mse_plot = gr.Plot(label="Combined MSE Plot")
120
+ correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
121
+
122
 
123
  df_store = gr.State()
124
  mse_features_store = gr.State()