Spaces:
Runtime error
Runtime error
refactor: apply upgraed SDK version
Browse files- src/obs_eval_gradio.py +40 -40
src/obs_eval_gradio.py
CHANGED
@@ -160,35 +160,35 @@ def show_audio_transcript(video_file, api_key):
|
|
160 |
return transcript
|
161 |
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
|
193 |
|
194 |
def call_gpt_vision(api_key, rubrics, progress=gr.Progress()) -> list:
|
@@ -369,7 +369,7 @@ def main():
|
|
369 |
columns=[5],
|
370 |
rows=[2],
|
371 |
object_fit="contain",
|
372 |
-
height="auto"
|
373 |
)
|
374 |
transcript_box = gr.Textbox(
|
375 |
label="Audio Transcript",
|
@@ -380,12 +380,12 @@ def main():
|
|
380 |
gr.Markdown("## 2nd STEP. Set Evaluation Rubric")
|
381 |
with gr.Row():
|
382 |
with gr.Column(scale=1):
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
rubric_video_input = gr.Textbox(
|
390 |
label="Video Evaluation Rubric",
|
391 |
info="Enter your evaluation rubric here...",
|
@@ -399,7 +399,7 @@ def main():
|
|
399 |
interactive=True,
|
400 |
visible=True,
|
401 |
lines=7
|
402 |
-
)
|
403 |
evaluate_button = gr.Button("Evaluate")
|
404 |
with gr.Column(scale=1):
|
405 |
video_output_box = gr.Textbox(
|
@@ -429,11 +429,11 @@ def main():
|
|
429 |
with gr.Column(scale=1):
|
430 |
output_box_fin_fin = gr.Textbox(label="Final Evaluation", lines=10, interactive=True)
|
431 |
|
432 |
-
|
433 |
-
|
434 |
|
435 |
process_button.click(fn=validate_api_key, inputs=api_key_input, outputs=None).success(fn=show_batches, inputs=[video_upload, batch_size, total_batch_percent], outputs=gallery).success(fn=show_audio_transcript, inputs=[video_upload, api_key_input], outputs=transcript_box)
|
436 |
-
if
|
437 |
evaluate_button.click(fn=call_gpt_vision, inputs=[api_key_input, rubric_video_input], outputs=video_output_box).then(fn=call_gpt_audio, inputs=[api_key_input, rubric_audio_input], outputs=audio_output_box).then(get_full_result, None, output_box_fin)
|
438 |
else:
|
439 |
evaluate_button.click(fn=call_gpt_vision, inputs=[api_key_input, rubric_video_input], outputs=video_output_box).then(get_full_result, None, output_box_fin)
|
|
|
160 |
return transcript
|
161 |
|
162 |
|
163 |
+
def change_audio_rubric(choice):
|
164 |
+
print(choice)
|
165 |
+
if choice == "Video only":
|
166 |
+
return gr.Textbox(
|
167 |
+
visible=False
|
168 |
+
)
|
169 |
+
else:
|
170 |
+
return gr.Textbox(
|
171 |
+
label="3. Audio Evaluation Rubric (if needed)",
|
172 |
+
info="Enter your evaluation rubric here...",
|
173 |
+
placeholder="<RUBRIC>\nHere's what the performer should *SAY* as follows:\n1. From standing, you need to shout 'Start' signal.\n2. Rock forward, you shouldn't make any noise while rolling.\n3. Standing still again, you need to shout 'Finish' signal.",
|
174 |
+
lines=7,
|
175 |
+
interactive=True,
|
176 |
+
visible=True)
|
177 |
+
|
178 |
+
|
179 |
+
def change_audio_eval(choice):
|
180 |
+
print(choice)
|
181 |
+
if choice == "Video only":
|
182 |
+
return gr.Textbox(
|
183 |
+
visible=False,
|
184 |
+
)
|
185 |
+
else:
|
186 |
+
return gr.Textbox(
|
187 |
+
label="Audio Script Eval...",
|
188 |
+
lines=10,
|
189 |
+
interactive=False,
|
190 |
+
visible=True
|
191 |
+
)
|
192 |
|
193 |
|
194 |
def call_gpt_vision(api_key, rubrics, progress=gr.Progress()) -> list:
|
|
|
369 |
columns=[5],
|
370 |
rows=[2],
|
371 |
object_fit="contain",
|
372 |
+
height="auto",
|
373 |
)
|
374 |
transcript_box = gr.Textbox(
|
375 |
label="Audio Transcript",
|
|
|
380 |
gr.Markdown("## 2nd STEP. Set Evaluation Rubric")
|
381 |
with gr.Row():
|
382 |
with gr.Column(scale=1):
|
383 |
+
multimodal_radio = gr.Radio(
|
384 |
+
label="1. Multimodal Selection",
|
385 |
+
info="Choose evaluation channel",
|
386 |
+
value="Video + Audio",
|
387 |
+
choices=["Video + Audio", "Video only"]
|
388 |
+
)
|
389 |
rubric_video_input = gr.Textbox(
|
390 |
label="Video Evaluation Rubric",
|
391 |
info="Enter your evaluation rubric here...",
|
|
|
399 |
interactive=True,
|
400 |
visible=True,
|
401 |
lines=7
|
402 |
+
)
|
403 |
evaluate_button = gr.Button("Evaluate")
|
404 |
with gr.Column(scale=1):
|
405 |
video_output_box = gr.Textbox(
|
|
|
429 |
with gr.Column(scale=1):
|
430 |
output_box_fin_fin = gr.Textbox(label="Final Evaluation", lines=10, interactive=True)
|
431 |
|
432 |
+
multimodal_radio.change(fn=change_audio_rubric, inputs=multimodal_radio, outputs=rubric_audio_input)
|
433 |
+
multimodal_radio.change(fn=change_audio_eval, inputs=multimodal_radio, outputs=audio_output_box)
|
434 |
|
435 |
process_button.click(fn=validate_api_key, inputs=api_key_input, outputs=None).success(fn=show_batches, inputs=[video_upload, batch_size, total_batch_percent], outputs=gallery).success(fn=show_audio_transcript, inputs=[video_upload, api_key_input], outputs=transcript_box)
|
436 |
+
if multimodal_radio.value == "Video + Audio":
|
437 |
evaluate_button.click(fn=call_gpt_vision, inputs=[api_key_input, rubric_video_input], outputs=video_output_box).then(fn=call_gpt_audio, inputs=[api_key_input, rubric_audio_input], outputs=audio_output_box).then(get_full_result, None, output_box_fin)
|
438 |
else:
|
439 |
evaluate_button.click(fn=call_gpt_vision, inputs=[api_key_input, rubric_video_input], outputs=video_output_box).then(get_full_result, None, output_box_fin)
|