Skip to content

Commit e318fc8

Browse files
author
Haozhe Qi
committed
updates
1 parent 10c3f7d commit e318fc8

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

llava/action/ek_eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def get_args_parser():
124124
'random_narration_cut', 'top1_narration_cut', 'topk_narration_cut_key',
125125
'GT_key', 'GT_random_narration', 'GT_random_narration_cut', 'gpt_narration'])
126126
parser.add_argument('--n_narrations', default = -1, type = int)
127-
parser.add_argument('--test_type', default = 'base', type = str, choices = ['caption', 'base', 'temporal_cot', 'temporal_cot_oracle', 'caption_then_answer', 'direct_narration'])
127+
parser.add_argument('--test_type', default = 'base', type = str, choices = ['caption', 'base', 'temporal_cot_caption', 'temporal_cot_pseudo', 'temporal_cot_oracle', 'caption_then_answer', 'direct_narration'])
128128
parser.add_argument('--learn_neighbor_actions', type= str, default = "")
129129
parser.add_argument('--pseudo_folder', default = None, type = str)
130130
parser.add_argument('--output_dir', default = None, type = str)

llava/action/generate_interval_pred.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_lookup_dict(ann_file, test_type = 'base', delta = 3, pseudo_folder = Non
130130
table = {}
131131

132132
pseudo_dict = None
133-
if test_type == 'temporal_cot':
133+
if test_type == 'temporal_cot_pseudo':
134134
assert os.path.exists(pseudo_folder), f"Folder {pseudo_folder} does not exist"
135135
pseudo_dict = get_pseudo_dict(pseudo_folder)
136136

@@ -159,11 +159,11 @@ def get_lookup_dict(ann_file, test_type = 'base', delta = 3, pseudo_folder = Non
159159
uid2 = f"{id}_{round(start_times[i+1],2)}_{round(end_times[i+1],2)}"
160160
uid3 = f"{id}_{round(start_times[i+2],2)}_{round(end_times[i+2],2)}"
161161

162-
if test_type == 'base' or test_type == 'temporal_cot_oracle':
162+
if test_type == 'base' or test_type.startswith('temporal_cot') and test_type != 'temporal_cot_pseudo':
163163
narration1 = sorted_narrations[i]
164164
narration2 = sorted_narrations[i+1]
165165
narration3 = sorted_narrations[i+2]
166-
elif test_type == 'temporal_cot':
166+
elif test_type == 'temporal_cot_pseudo':
167167
narration1 = pseudo_dict[uid1]
168168
narration2 = pseudo_dict[uid2]
169169
narration3 = sorted_narrations[i+2]

llava/action/llava_inference.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ def llava_inference(
5353
question_type = "direct_narration"
5454
elif test_type == 'caption' or test_type == 'debug':
5555
question_type = "caption"
56-
elif test_type == 'temporal_cot':
57-
question_type = 'temporal_cot'
56+
elif test_type == 'temporal_cot_pseudo':
57+
question_type = 'temporal_cot_pseudo'
5858
elif test_type == 'temporal_cot_oracle':
59-
question_type = 'temporal_cot_oracle'
59+
question_type = 'temporal_cot_oracle'
60+
elif test_type == 'temporal_cot_caption':
61+
question_type = 'temporal_cot_caption'
6062

6163
if test_type == 'caption_then_answer':
6264
caption_answer = llava_inference([video_frames],

llava/action/utils.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,15 @@ def format_task_related_prompt(question, question_type, meta_data = None, perspe
250250
ret = prefix + suffix
251251
elif question_type.startswith("temporal_cot") and learn_neighbor_actions == "prior" and meta_data:
252252
# means it's test time
253-
prefix = f"{perspective_prefix}\n"
254-
assert isinstance(question, list)
255-
suffix = ", ".join(question)
256-
suffix = f"{prev2_offset} seconds ago, you started an action {prev2_narration}. {prev1_offset} seconds ago, you started an action {prev1_narration}. What action are you currently performing? Here are the options of actions you can select:\n" + suffix
257-
ret = prefix + suffix
258-
rank0_print('debug')
259-
rank0_print (meta_data)
260-
rank0_print (ret)
253+
if question_type == 'temporal_cot_caption':
254+
ret = f"{perspective_prefix} {prev2_offset} seconds ago, you started an action {prev2_narration}. {prev1_offset} seconds ago, you started an action {prev1_narration}. Describe in details what you see from the video frames. You must talk in the first person perspective. Try to focus on what you are doing."
255+
rank0_print(ret)
256+
else:
257+
prefix = f"{perspective_prefix}\n"
258+
assert isinstance(question, list)
259+
suffix = ", ".join(question)
260+
suffix = f"{prev2_offset} seconds ago, you started an action {prev2_narration}. {prev1_offset} seconds ago, you started an action {prev1_narration}. What action are you currently performing? Here are the options of actions you can select:\n" + suffix
261+
ret = prefix + suffix
261262

262263
else:
263264
action_rep_suffix = "Given multiple choices, format your answer briefly such as 'A. move knife'. "

0 commit comments

Comments
 (0)