reab5555 commited on
Commit
00c602a
·
verified ·
1 Parent(s): 3b4df7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -25
app.py CHANGED
@@ -58,30 +58,14 @@ def analyze_video(video_path, progress=gr.Progress()):
58
 
59
  # Pad with None for any missing speakers
60
  while len(output_components) < 28:
61
- output_components.append(None)
62
 
63
  output_components.append(f"Completed in {int(execution_time)} seconds.") # execution info
64
 
65
  return output_components
66
 
67
  def update_output(*args):
68
- updated_components = []
69
- for i in range(0, len(args) - 1, 10): # 9 components per speaker + 1 column
70
- column_components = args[i:i+9]
71
- column = args[i+9]
72
-
73
- if any(comp is not None for comp in column_components):
74
- updated_components.extend([gr.update(value=arg, visible=arg is not None) for arg in column_components])
75
- updated_components.append(gr.update(visible=True)) # Make the column visible
76
- else:
77
- updated_components.extend([gr.update(visible=False) for _ in range(9)])
78
- updated_components.append(gr.update(visible=False)) # Hide the empty column
79
-
80
- # Handle transcript and execution info
81
- updated_components.insert(0, gr.update(value=args[0], visible=args[0] is not None))
82
- updated_components.append(gr.update(value=args[-1], visible=args[-1] is not None))
83
-
84
- return updated_components
85
 
86
  def use_example():
87
  return "examples/Scenes.From.A.Marriage.US.mp4"
@@ -105,10 +89,9 @@ with gr.Blocks() as iface:
105
  # Add transcript output near the top
106
  execution_info_box = gr.Textbox(label="Transcript", value="N/A", lines=1)
107
  output_components.append(execution_info_box)
108
-
109
  with gr.Row():
110
  for i in range(3): # Assuming maximum of 3 speakers
111
- with gr.Column(visible=False) as column:
112
  column_components = [
113
  gr.Markdown(visible=False),
114
  gr.Textbox(label="General Impression", visible=False),
@@ -121,7 +104,6 @@ with gr.Blocks() as iface:
121
  gr.Textbox(label="Personality Disorders Explanation", visible=False),
122
  ]
123
  output_components.extend(column_components)
124
- output_components.append(column)
125
 
126
  # Add execution info component
127
  transcript_output = gr.Textbox(label="Transcript", lines=10, visible=False)
@@ -132,10 +114,6 @@ with gr.Blocks() as iface:
132
  inputs=[video_input],
133
  outputs=output_components,
134
  show_progress=True
135
- ).then(
136
- fn=update_output,
137
- inputs=output_components,
138
- outputs=output_components
139
  )
140
 
141
  use_example_button.click(
 
58
 
59
  # Pad with None for any missing speakers
60
  while len(output_components) < 28:
61
+ output_components.extend([gr.update(visible=False)] * 9)
62
 
63
  output_components.append(f"Completed in {int(execution_time)} seconds.") # execution info
64
 
65
  return output_components
66
 
67
  def update_output(*args):
68
+ return [gr.update(value=arg, visible=arg is not None) for arg in args]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  def use_example():
71
  return "examples/Scenes.From.A.Marriage.US.mp4"
 
89
  # Add transcript output near the top
90
  execution_info_box = gr.Textbox(label="Transcript", value="N/A", lines=1)
91
  output_components.append(execution_info_box)
 
92
  with gr.Row():
93
  for i in range(3): # Assuming maximum of 3 speakers
94
+ with gr.Column():
95
  column_components = [
96
  gr.Markdown(visible=False),
97
  gr.Textbox(label="General Impression", visible=False),
 
104
  gr.Textbox(label="Personality Disorders Explanation", visible=False),
105
  ]
106
  output_components.extend(column_components)
 
107
 
108
  # Add execution info component
109
  transcript_output = gr.Textbox(label="Transcript", lines=10, visible=False)
 
114
  inputs=[video_input],
115
  outputs=output_components,
116
  show_progress=True
 
 
 
 
117
  )
118
 
119
  use_example_button.click(