Armen Gabrielyan commited on
Commit
0f78704
1 Parent(s): cde7ed6

output top 3 results

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -45,8 +45,12 @@ def search_in_video(video, query):
45
 
46
  ordered_similarity_scores = similarities[0][arg_sorted_similarities]
47
 
48
- best_video = video_segments[arg_sorted_similarities[0, -1]]
49
- torchvision.io.write_video('best.mp4', best_video, video_fps)
 
 
 
 
50
 
51
  total_frames = video.shape[0]
52
 
@@ -70,11 +74,16 @@ def search_in_video(video, query):
70
  zip(ordered_start_ends[0].tolist(), ordered_similarity_scores[0].tolist())
71
  )
72
 
73
- return 'best.mp4', labels_to_scores
74
 
75
  app = gr.Interface(
76
  fn=search_in_video,
77
  inputs=['video', 'text'],
78
- outputs=['video', gr.outputs.Label(num_top_classes=3, type='auto')],
 
 
 
 
 
79
  )
80
  app.launch()
 
45
 
46
  ordered_similarity_scores = similarities[0][arg_sorted_similarities]
47
 
48
+ top1 = video_segments[arg_sorted_similarities[0, -1]]
49
+ top2 = video_segments[arg_sorted_similarities[0, -2]]
50
+ top3 = video_segments[arg_sorted_similarities[0, -3]]
51
+ torchvision.io.write_video('top1.mp4', top1, video_fps)
52
+ torchvision.io.write_video('top2.mp4', top2, video_fps)
53
+ torchvision.io.write_video('top3.mp4', top3, video_fps)
54
 
55
  total_frames = video.shape[0]
56
 
 
74
  zip(ordered_start_ends[0].tolist(), ordered_similarity_scores[0].tolist())
75
  )
76
 
77
+ return 'top1.mp4', 'top2.mp4', 'top3.mp4', labels_to_scores
78
 
79
  app = gr.Interface(
80
  fn=search_in_video,
81
  inputs=['video', 'text'],
82
+ outputs=[
83
+ gr.Video(format='mp4', label='Top1'),
84
+ gr.Video(format='mp4', label='Top2'),
85
+ gr.Video(format='mp4', label='Top3'),
86
+ gr.outputs.Label(num_top_classes=5, type='auto', label='Scores'),
87
+ ],
88
  )
89
  app.launch()