Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit c3628a1

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/DFOL-VQA into main
2 parents 7a76976 + 94e9ad2 commit c3628a1

8 files changed

Lines changed: 15 additions & 6 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

src/.DS_Store

6 KB
Binary file not shown.

src/gqa_preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ def _parse_compare(self, op_tokens, arg_tokens):
384384
gqap.preprocess(args['input_file'], join(output_path, 'p_' + input_file + '.json'), True, args['length_segregation'], discard_global=args['discard_global'])
385385

386386
if args['h5']:
387-
ATTRIBUTE_PATH = "./nsvqa/data/metadata/gqa_attribute.json"
388-
CLASS_PATH = "./nsvqa/data/metadata/gqa_class_clean.json"
387+
ATTRIBUTE_PATH = "./nsvqa/data/metadata/gqa_all_attribute.json"
388+
CLASS_PATH = "./nsvqa/data/metadata/gqa_all_class.json"
389389
VOCAB_PATH = "./nsvqa/data/metadata/gqa_vocab.json"
390390

391391
ontology = GQAOntology(ATTRIBUTE_PATH, CLASS_PATH, VOCAB_PATH)

src/nsvqa/.DS_Store

6 KB
Binary file not shown.

src/nsvqa/data/batch_gqa_boxfeatures_pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ def collate_meta_data(self, questions):
162162
relations = np.zeros((len(image_idx), self._max_relation_per_image, self._relation_feature_dim))
163163
pair_indices = np.zeros((len(image_idx), self._max_relation_per_image, 2))
164164

165+
object_nums_cum_sum = np.array(object_nums, dtype=np.int64).cumsum()
166+
165167
for j, (chunck_id, offset) in enumerate(zip(image_chk, image_idx)):
166168
relations[j, :, :] = self._file_handles[chunck_id]['relation_features'][offset, :, :]
167-
pair_indices[j, :, :] = self._file_handles[chunck_id]['relation_indices'][offset, :, :] + (object_nums[j - 1] if j > 0 else 0)
169+
pair_indices[j, :, :] = self._file_handles[chunck_id]['relation_indices'][offset, :, :] + (object_nums_cum_sum[j - 1] if j > 0 else 0)
168170

169171
relations = relations.reshape((-1, self._relation_feature_dim))
170172
pair_indices = pair_indices.reshape((-1, 2))

src/nsvqa/nn/.DS_Store

6 KB
Binary file not shown.

src/nsvqa/nn/interpreter/batch_base_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def forward(self, op_id, world, subject_variable_set, object_variable_set, relat
583583
object_variable_set.object_num(), predicate_num, quantifiers=quantifier,
584584
log_attention=log_attention_posterior[:, 1, :], batch_object_map=object_variable_set._batch_object_map,
585585
predicate_question_map=predicate_question_map, base_cumulative_loss=subject_variable_set.cumulative_loss() + object_variable_set.cumulative_loss(),
586-
prev_variable_sets_num=subject_variable_set._prev_variable_sets_num + object_variable_set._prev_variable_sets_num + 1)
586+
prev_variable_sets_num=subject_variable_set._prev_variable_sets_num + object_variable_set._prev_variable_sets_num + 1).to(object_variable_set.dtype)
587587

588588
if op_id in self._subject_modulations:
589589
new_subject_set = new_subject_set.apply_modulations(self._subject_modulations[op_id], subject_variable_set, predicate_question_map).to(subject_variable_set.dtype)

src/nsvqa/nn/vision/classifier_oracle.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ def compute_all_log_likelihood(self, object_features, pair_object_features):
143143
return attr_output, rel_output
144144

145145
def compute_all_log_likelihood_2(self, object_features, pair_object_features):
146-
attr_output = self._embedding_network(self._attribute_network(object_features))
147-
rel_output = self._embedding_network(self._relation_network(pair_object_features))[:, self._ontology._relation_index]
146+
if self._embedding_network is None or self._attribute_network is None:
147+
attr_output = object_features
148+
else:
149+
attr_output = self._embedding_network(self._attribute_network(object_features))
150+
151+
if self._embedding_network is None or self._relation_network is None:
152+
rel_output = pair_object_features
153+
else:
154+
rel_output = self._embedding_network(self._relation_network(pair_object_features))[:, self._ontology._relation_index]
148155

149156
return attr_output, rel_output

0 commit comments

Comments
 (0)