Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from config import openai_api_key
|
|
10 |
# Load the model
|
11 |
llm = load_model(openai_api_key)
|
12 |
|
|
|
13 |
def analyze_video(video_path, progress=gr.Progress()):
|
14 |
start_time = time.time()
|
15 |
if not video_path:
|
@@ -40,57 +41,55 @@ def analyze_video(video_path, progress=gr.Progress()):
|
|
40 |
print(speaker_id)
|
41 |
speaker_explanations = explanations[speaker_id]
|
42 |
speaker_general_impression = general_impressions[speaker_id]
|
43 |
-
|
44 |
with gr.Tab():
|
45 |
-
with gr.TabItem(label=f'General Impression'):
|
46 |
speaker_section1 = [
|
47 |
gr.Markdown(f"### {speaker_id}", visible=True),
|
48 |
gr.Textbox(value=speaker_general_impression, label="General Impression", visible=True)
|
49 |
]
|
50 |
-
|
51 |
with gr.TabItem(label=f'Attachment Styles'):
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
]
|
61 |
-
|
62 |
-
speaker_section2_2 = [gr.Textbox(value=speaker_explanations.get("attachment", ""), label="Attachment Styles Explanation", visible=True)]
|
63 |
-
|
64 |
-
with gr.TabItem(label=f'Big Five Traits'):
|
65 |
speaker_section3 = [
|
66 |
gr.Plot(value=speaker_charts.get("bigfive", None), visible=True),
|
67 |
-
gr.Textbox(value=speaker_explanations.get("bigfive", ""), label="Big Five Traits Explanation",
|
|
|
68 |
]
|
69 |
-
|
70 |
-
with gr.TabItem(label=f'Personalities'):
|
71 |
-
speaker_section4 = [
|
72 |
gr.Plot(value=speaker_charts.get("personality", None), visible=True),
|
73 |
-
gr.Textbox(value=speaker_explanations.get("personality", ""),
|
|
|
74 |
]
|
75 |
-
|
76 |
output_components.extend(speaker_section1)
|
77 |
-
output_components.extend(
|
78 |
-
output_components.extend(speaker_section2_2)
|
79 |
output_components.extend(speaker_section3)
|
80 |
output_components.extend(speaker_section4)
|
81 |
|
82 |
# Pad with None for any missing speakers
|
83 |
while len(output_components) < 28:
|
84 |
output_components.extend([gr.update(visible=False)] * 9)
|
85 |
-
|
86 |
return output_components
|
87 |
|
|
|
88 |
def use_example():
|
89 |
return "examples/Scenes.From.A.Marriage.US.mp4"
|
90 |
|
|
|
91 |
with gr.Blocks() as iface:
|
92 |
gr.Markdown("# AI Personality Detection")
|
93 |
-
|
94 |
with gr.Row():
|
95 |
with gr.Column(scale=3):
|
96 |
gr.Markdown("Upload a video")
|
@@ -110,39 +109,31 @@ with gr.Blocks() as iface:
|
|
110 |
transcript = gr.Textbox(label="Transcript", lines=10, visible=False)
|
111 |
output_components.append(transcript)
|
112 |
|
113 |
-
|
114 |
for n in range(3): # Assuming maximum of 3 speakers
|
115 |
-
with gr.Tab(label=f'Speaker {n+1}', visible=True):
|
116 |
-
with gr.TabItem(label=f'General Impression'):
|
117 |
column_components1 = [
|
118 |
gr.Markdown(visible=False),
|
119 |
gr.Textbox(label="General Impression", visible=False)]
|
120 |
-
|
121 |
with gr.TabItem(label=f'Attachment Styles'):
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
gr.Column(scale=1, components=[
|
128 |
-
gr.Plot(visible=False)
|
129 |
-
])
|
130 |
-
]
|
131 |
-
column_components2_2 = [gr.Textbox(label="Attachment Styles Explanation", visible=False)]
|
132 |
-
|
133 |
with gr.TabItem(label=f'Big Five Traits'):
|
134 |
column_components3 = [
|
135 |
gr.Plot(visible=False),
|
136 |
gr.Textbox(label="Big Five Traits Explanation", visible=False)]
|
137 |
-
|
138 |
with gr.TabItem(label=f'Personalities'):
|
139 |
column_components4 = [
|
140 |
gr.Plot(visible=False),
|
141 |
gr.Textbox(label="Personality Disorders Explanation", visible=False)]
|
142 |
-
|
143 |
output_components.extend(column_components1)
|
144 |
-
output_components.extend(
|
145 |
-
output_components.extend(column_components2_2)
|
146 |
output_components.extend(column_components3)
|
147 |
output_components.extend(column_components4)
|
148 |
|
@@ -158,10 +149,10 @@ with gr.Blocks() as iface:
|
|
158 |
inputs=[],
|
159 |
outputs=[video_input],
|
160 |
).then(fn=analyze_video,
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
if __name__ == "__main__":
|
167 |
iface.launch()
|
|
|
10 |
# Load the model
|
11 |
llm = load_model(openai_api_key)
|
12 |
|
13 |
+
|
14 |
def analyze_video(video_path, progress=gr.Progress()):
|
15 |
start_time = time.time()
|
16 |
if not video_path:
|
|
|
41 |
print(speaker_id)
|
42 |
speaker_explanations = explanations[speaker_id]
|
43 |
speaker_general_impression = general_impressions[speaker_id]
|
44 |
+
|
45 |
with gr.Tab():
|
46 |
+
with gr.TabItem(label=f'General Impression'):
|
47 |
speaker_section1 = [
|
48 |
gr.Markdown(f"### {speaker_id}", visible=True),
|
49 |
gr.Textbox(value=speaker_general_impression, label="General Impression", visible=True)
|
50 |
]
|
51 |
+
|
52 |
with gr.TabItem(label=f'Attachment Styles'):
|
53 |
+
speaker_section2 = [
|
54 |
+
gr.Plot(value=speaker_charts.get("attachment", None), visible=True),
|
55 |
+
gr.Plot(value=speaker_charts.get("dimensions", None), visible=True),
|
56 |
+
gr.Textbox(value=speaker_explanations.get("attachment", ""), label="Attachment Styles Explanation",
|
57 |
+
visible=True)
|
58 |
+
]
|
59 |
+
|
60 |
+
with gr.TabItem(label=f'Big Five Traits'):
|
|
|
|
|
|
|
|
|
|
|
61 |
speaker_section3 = [
|
62 |
gr.Plot(value=speaker_charts.get("bigfive", None), visible=True),
|
63 |
+
gr.Textbox(value=speaker_explanations.get("bigfive", ""), label="Big Five Traits Explanation",
|
64 |
+
visible=True)
|
65 |
]
|
66 |
+
|
67 |
+
with gr.TabItem(label=f'Personalities'):
|
68 |
+
speaker_section4 = [
|
69 |
gr.Plot(value=speaker_charts.get("personality", None), visible=True),
|
70 |
+
gr.Textbox(value=speaker_explanations.get("personality", ""),
|
71 |
+
label="Personality Disorders Explanation", visible=True)
|
72 |
]
|
73 |
+
|
74 |
output_components.extend(speaker_section1)
|
75 |
+
output_components.extend(speaker_section2)
|
|
|
76 |
output_components.extend(speaker_section3)
|
77 |
output_components.extend(speaker_section4)
|
78 |
|
79 |
# Pad with None for any missing speakers
|
80 |
while len(output_components) < 28:
|
81 |
output_components.extend([gr.update(visible=False)] * 9)
|
82 |
+
|
83 |
return output_components
|
84 |
|
85 |
+
|
86 |
def use_example():
|
87 |
return "examples/Scenes.From.A.Marriage.US.mp4"
|
88 |
|
89 |
+
|
90 |
with gr.Blocks() as iface:
|
91 |
gr.Markdown("# AI Personality Detection")
|
92 |
+
|
93 |
with gr.Row():
|
94 |
with gr.Column(scale=3):
|
95 |
gr.Markdown("Upload a video")
|
|
|
109 |
transcript = gr.Textbox(label="Transcript", lines=10, visible=False)
|
110 |
output_components.append(transcript)
|
111 |
|
|
|
112 |
for n in range(3): # Assuming maximum of 3 speakers
|
113 |
+
with gr.Tab(label=f'Speaker {n + 1}', visible=True):
|
114 |
+
with gr.TabItem(label=f'General Impression'):
|
115 |
column_components1 = [
|
116 |
gr.Markdown(visible=False),
|
117 |
gr.Textbox(label="General Impression", visible=False)]
|
118 |
+
|
119 |
with gr.TabItem(label=f'Attachment Styles'):
|
120 |
+
column_components2 = [
|
121 |
+
gr.Plot(visible=False),
|
122 |
+
gr.Plot(visible=False),
|
123 |
+
gr.Textbox(label="Attachment Styles Explanation", visible=False)]
|
124 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
with gr.TabItem(label=f'Big Five Traits'):
|
126 |
column_components3 = [
|
127 |
gr.Plot(visible=False),
|
128 |
gr.Textbox(label="Big Five Traits Explanation", visible=False)]
|
129 |
+
|
130 |
with gr.TabItem(label=f'Personalities'):
|
131 |
column_components4 = [
|
132 |
gr.Plot(visible=False),
|
133 |
gr.Textbox(label="Personality Disorders Explanation", visible=False)]
|
134 |
+
|
135 |
output_components.extend(column_components1)
|
136 |
+
output_components.extend(column_components2)
|
|
|
137 |
output_components.extend(column_components3)
|
138 |
output_components.extend(column_components4)
|
139 |
|
|
|
149 |
inputs=[],
|
150 |
outputs=[video_input],
|
151 |
).then(fn=analyze_video,
|
152 |
+
inputs=[video_input],
|
153 |
+
outputs=output_components,
|
154 |
+
show_progress=True
|
155 |
+
)
|
156 |
|
157 |
if __name__ == "__main__":
|
158 |
iface.launch()
|