ManishThota commited on
Commit
9871891
1 Parent(s): 24e62e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -8
app.py CHANGED
@@ -1,14 +1,83 @@
1
- # Importing the requirements
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import warnings
3
  warnings.filterwarnings("ignore")
4
-
5
  import gradio as gr
6
- from src.video_model import describe_video
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Video and text inputs for the interface
10
  video = gr.Video(label="Video")
11
- query = gr.Textbox(label="Question", placeholder="Enter your question here")
 
 
 
 
 
 
12
 
13
  # Output for the interface
14
  response = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)
@@ -33,11 +102,10 @@ title = "GSoC Super Raid Annotator"
33
  description = "Annotate Videos"
34
  article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"
35
 
36
-
37
  # Launch the interface
38
  interface = gr.Interface(
39
- fn=describe_video,
40
- inputs=[video, query],
41
  outputs=response,
42
  examples=examples,
43
  title=title,
@@ -46,4 +114,4 @@ interface = gr.Interface(
46
  theme="Soft",
47
  allow_flagging="never",
48
  )
49
- interface.launch(debug=False)
 
1
+ # # Importing the requirements
2
+ # import warnings
3
+ # warnings.filterwarnings("ignore")
4
+
5
+ # import gradio as gr
6
+ # from src.video_model import describe_video
7
+
8
+
9
+ # # Video and text inputs for the interface
10
+ # video = gr.Video(label="Video")
11
+ # query = gr.Textbox(label="Question", placeholder="Enter your question here")
12
+
13
+ # # Output for the interface
14
+ # response = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)
15
+
16
+ # # Examples for the interface
17
+ # examples = [
18
+ # [
19
+ # "videos/2016-01-01_0100_US_KNBC_Channel_4_News_1867.16-1871.38_now.mp4",
20
+ # "Here are some frames of a video. Describe this video in detail."
21
+ # ],
22
+ # [
23
+ # "videos/2016-01-01_0200_US_KNBC_Channel_4_News_1329.12-1333.29_tonight.mp4",
24
+ # "Here are some frames of a video. Describe this video in detail."
25
+ # ],
26
+ # [ "videos/2016-01-01_0830_US_KNBC_Tonight_Show_with_Jimmy_Fallon_725.45-729.76_tonight.mp4",
27
+ # "Here are some frames of a video. Describe this video in detail."
28
+ # ]
29
+ # ]
30
+
31
+ # # Title, description, and article for the interface
32
+ # title = "GSoC Super Raid Annotator"
33
+ # description = "Annotate Videos"
34
+ # article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"
35
+
36
+
37
+ # # Launch the interface
38
+ # interface = gr.Interface(
39
+ # fn=describe_video,
40
+ # inputs=[video, query],
41
+ # outputs=response,
42
+ # examples=examples,
43
+ # title=title,
44
+ # description=description,
45
+ # article=article,
46
+ # theme="Soft",
47
+ # allow_flagging="never",
48
+ # )
49
+ # interface.launch(debug=False)
50
+
51
  import warnings
52
  warnings.filterwarnings("ignore")
 
53
  import gradio as gr
54
+ from src.video_model import describe_video # Assuming this function processes the video and query
55
 
56
+ def process_video_and_questions(video, query, sitting, hands, location, screen):
57
+ additional_info = []
58
+ if sitting:
59
+ additional_info.append("Is the subject in the video standing or sitting?")
60
+ if hands:
61
+ additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free.?")
62
+ if location:
63
+ additional_info.append("Is the subject present indoors or outdoors?")
64
+ if screen:
65
+ additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
66
+
67
+ final_query = query + " " + " ".join(additional_info)
68
+ # Assuming your describe_video function handles the video processing
69
+ response = describe_video(video, final_query)
70
+ return response
71
 
72
  # Video and text inputs for the interface
73
  video = gr.Video(label="Video")
74
+ query = gr.Textbox(label="Question", value="Here are some frames of a video. Describe this video in detail and answer the below questions.", placeholder="Enter your question here")
75
+
76
+ # Options as checkboxes
77
+ sitting = gr.Checkbox(label="Sitting/Standing")
78
+ hands = gr.Checkbox(label="Hands Free/Not Free")
79
+ location = gr.Checkbox(label="Indoors/Outdoors")
80
+ screen = gr.Checkbox(label="Screen Interaction")
81
 
82
  # Output for the interface
83
  response = gr.Textbox(label="Predicted answer", show_label=True, show_copy_button=True)
 
102
  description = "Annotate Videos"
103
  article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"
104
 
 
105
  # Launch the interface
106
  interface = gr.Interface(
107
+ fn=process_video_and_questions, # Updated function to handle the query construction
108
+ inputs=[video, query, sitting, hands, location, screen],
109
  outputs=response,
110
  examples=examples,
111
  title=title,
 
114
  theme="Soft",
115
  allow_flagging="never",
116
  )
117
+ interface.launch(debug=False)