ManishThota commited on
Commit
88cedc3
·
verified ·
1 Parent(s): 3035f99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -15
app.py CHANGED
@@ -6,7 +6,42 @@ from src.video_model import describe_video
6
  from src.utils import parse_string, parse_annotations
7
  import os
8
 
9
- # --- Function to construct the final query ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def process_video_and_questions(video, sitting, hands, location, screen):
11
  # Extract the video name (filename)
12
  video_name = os.path.basename(video)
@@ -14,32 +49,45 @@ def process_video_and_questions(video, sitting, hands, location, screen):
14
  # Construct the query with the video name included
15
  query = f"Describe the video in detail and answer the questions"
16
  additional_info = []
17
- if sitting:
 
 
18
  additional_info.append("Is the subject in the video standing or sitting?")
19
- if hands:
 
 
 
20
  additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free?")
21
- if location:
 
 
 
22
  additional_info.append("Is the subject present indoors or outdoors?")
23
- if screen:
 
 
 
24
  additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
 
 
25
 
 
26
  end_query = """Provide the results in <annotation> tags, where 0 indicates False, 1 indicates True, and None indicates that no information is present. Below is an example:
27
- <instructions>
28
- <annotation>indoors: 0</annotation>
29
- <annotation>standing: 1</annotation>
30
- <annotation>hands.free: None</annotation>
31
- <annotation>screen.interaction_yes: None</annotation>
32
- </instructions>
33
-
34
- """
35
-
36
  final_query = query + " " + " ".join(additional_info)
37
  final_prompt = final_query + " " + end_query
38
 
39
  # Assuming your describe_video function handles the video processing
40
  response = describe_video(video, final_prompt)
41
  final_response = f"<video_name>{video_name}</video_name>" + " " + response
42
- return final_response
 
43
 
44
 
45
  def output_to_csv(final_response):
 
6
  from src.utils import parse_string, parse_annotations
7
  import os
8
 
9
+ # # --- Function to construct the final query ---
10
+ # def process_video_and_questions(video, sitting, hands, location, screen):
11
+ # # Extract the video name (filename)
12
+ # video_name = os.path.basename(video)
13
+
14
+ # # Construct the query with the video name included
15
+ # query = f"Describe the video in detail and answer the questions"
16
+ # additional_info = []
17
+ # if sitting:
18
+ # additional_info.append("Is the subject in the video standing or sitting?")
19
+ # if hands:
20
+ # additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free?")
21
+ # if location:
22
+ # additional_info.append("Is the subject present indoors or outdoors?")
23
+ # if screen:
24
+ # additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
25
+
26
+ # end_query = """Provide the results in <annotation> tags, where 0 indicates False, 1 indicates True, and None indicates that no information is present. Below is an example:
27
+ # <instructions>
28
+ # <annotation>indoors: 0</annotation>
29
+ # <annotation>standing: 1</annotation>
30
+ # <annotation>hands.free: None</annotation>
31
+ # <annotation>screen.interaction_yes: None</annotation>
32
+ # </instructions>
33
+
34
+ # """
35
+
36
+
37
+ # final_query = query + " " + " ".join(additional_info)
38
+ # final_prompt = final_query + " " + end_query
39
+
40
+ # # Assuming your describe_video function handles the video processing
41
+ # response = describe_video(video, final_prompt)
42
+ # final_response = f"<video_name>{video_name}</video_name>" + " " + response
43
+ # return final_response
44
+
45
  def process_video_and_questions(video, sitting, hands, location, screen):
46
  # Extract the video name (filename)
47
  video_name = os.path.basename(video)
 
49
  # Construct the query with the video name included
50
  query = f"Describe the video in detail and answer the questions"
51
  additional_info = []
52
+
53
+ # Handle each checkbox option, including those not selected (None)
54
+ if sitting is not None:
55
  additional_info.append("Is the subject in the video standing or sitting?")
56
+ else:
57
+ additional_info.append("<annotation>standing: None</annotation>")
58
+
59
+ if hands is not None:
60
  additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free?")
61
+ else:
62
+ additional_info.append("<annotation>hands.free: None</annotation>")
63
+
64
+ if location is not None:
65
  additional_info.append("Is the subject present indoors or outdoors?")
66
+ else:
67
+ additional_info.append("<annotation>indoors: None</annotation>")
68
+
69
+ if screen is not None:
70
  additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
71
+ else:
72
+ additional_info.append("<annotation>screen.interaction_yes: None</annotation>")
73
 
74
+ # Updated end_query string with clear explanation and example
75
  end_query = """Provide the results in <annotation> tags, where 0 indicates False, 1 indicates True, and None indicates that no information is present. Below is an example:
76
+
77
+ <annotation>indoors: 0</annotation>
78
+ <annotation>standing: 1</annotation>
79
+ <annotation>hands.free: None</annotation>
80
+ <annotation>screen.interaction_yes: None</annotation>
81
+ """
82
+
 
 
83
  final_query = query + " " + " ".join(additional_info)
84
  final_prompt = final_query + " " + end_query
85
 
86
  # Assuming your describe_video function handles the video processing
87
  response = describe_video(video, final_prompt)
88
  final_response = f"<video_name>{video_name}</video_name>" + " " + response
89
+ return final_response
90
+
91
 
92
 
93
  def output_to_csv(final_response):