arjunanand13 commited on
Commit
5c4a19d
1 Parent(s): c6faaf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -216,8 +216,9 @@ class VideoClassifier:
216
 
217
  return self.client(inputs, parameters)
218
 
219
- def classify_video(self,video_input,checkbox):
220
  global classification_time , caption_time
 
221
  # transcript=self.audio_extraction_space(video_input)
222
  try:
223
  transcript=self.audio_extraction(video_input)
@@ -232,6 +233,8 @@ class VideoClassifier:
232
  # except:
233
  # transcript=self.audio_extraction_space(video_input)
234
  start_time_caption = time.time()
 
 
235
  if checkbox=="Image Captions":
236
  video = cv2.VideoCapture(video_input)
237
  length = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
@@ -259,8 +262,7 @@ class VideoClassifier:
259
  cv2.destroyAllWindows()
260
 
261
  # print("TIME TAKEN FOR IMAGE CAPTIONING", end_time_caption-start_time_caption)
262
- else:
263
- captions=""
264
  end_time_caption = time.time()
265
  caption_time=end_time_caption-start_time_caption
266
  start_time_generation = time.time()
@@ -461,17 +463,24 @@ class VideoClassifier:
461
 
462
  )
463
 
 
 
 
 
 
 
 
 
 
464
  checkbox = gr.CheckboxGroup(
465
- ["Image Captions"],
 
 
466
  )
467
- demo = gr.Interface(fn=self.classify_video, inputs=["playablevideo",checkbox],allow_flagging='never', examples=[
468
- # Each example should be a sublist with corresponding values for each input component
469
- [os.path.join(os.path.dirname(__file__), "American_football_heads_to_India_clip.mp4"), ["Image Captions"]],
470
- [os.path.join(os.path.dirname(__file__), "PersonalFinance_clip.mp4"), ["Image Captions"]],
471
- [os.path.join(os.path.dirname(__file__), "Motorcycle_clip.mp4"), ["Image Captions"]],
472
- [os.path.join(os.path.dirname(__file__), "Spirituality_1_clip.mp4"), ["Image Captions"]],
473
- [os.path.join(os.path.dirname(__file__), "Science_clip.mp4"), ["Image Captions"]],
474
- ],
475
  cache_examples=False, outputs=["text"],
476
  css=css_code, title="Interactive Advertising Bureau (IAB) compliant Video-Ad classification")
477
  # demo.launch(debug=True)
 
216
 
217
  return self.client(inputs, parameters)
218
 
219
+ def classify_video(self,video_input,checkbox=default_checkbox):
220
  global classification_time , caption_time
221
+ print("checkbox",checkbox)
222
  # transcript=self.audio_extraction_space(video_input)
223
  try:
224
  transcript=self.audio_extraction(video_input)
 
233
  # except:
234
  # transcript=self.audio_extraction_space(video_input)
235
  start_time_caption = time.time()
236
+ captions = ""
237
+
238
  if checkbox=="Image Captions":
239
  video = cv2.VideoCapture(video_input)
240
  length = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
 
262
  cv2.destroyAllWindows()
263
 
264
  # print("TIME TAKEN FOR IMAGE CAPTIONING", end_time_caption-start_time_caption)
265
+
 
266
  end_time_caption = time.time()
267
  caption_time=end_time_caption-start_time_caption
268
  start_time_generation = time.time()
 
463
 
464
  )
465
 
466
+ video_examples = [
467
+ [os.path.join(os.path.dirname(__file__), "American_football_heads_to_India_clip.mp4")],
468
+ [os.path.join(os.path.dirname(__file__), "PersonalFinance_clip.mp4")],
469
+ [os.path.join(os.path.dirname(__file__), "Motorcycle_clip.mp4")],
470
+ [os.path.join(os.path.dirname(__file__), "Spirituality_1_clip.mp4")],
471
+ [os.path.join(os.path.dirname(__file__), "Science_clip.mp4")]
472
+ ]
473
+
474
+ # Define the checkbox for additional feature control
475
  checkbox = gr.CheckboxGroup(
476
+ ["Image Captions"],
477
+ label="Features",
478
+ info="Select features for video classification",
479
  )
480
+
481
+ default_checkbox = []
482
+
483
+ demo = gr.Interface(fn=self.classify_video, inputs=["playablevideo",checkbox],allow_flagging='never', examples=video_examples,
 
 
 
 
484
  cache_examples=False, outputs=["text"],
485
  css=css_code, title="Interactive Advertising Bureau (IAB) compliant Video-Ad classification")
486
  # demo.launch(debug=True)