vlm_clone_2 / VILA /scripts /convert_gqa_for_eval.py
tuandunghcmut's picture
Add files using upload-large-folder tool
1c3d47d verified
# Copyright 2024 NVIDIA CORPORATION & AFFILIATES
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument("--src", type=str)
parser.add_argument("--dst", type=str)
args = parser.parse_args()
all_answers = []
for line_idx, line in enumerate(open(args.src)):
res = json.loads(line)
question_id = res["question_id"]
text = res["text"].rstrip(".").lower()
all_answers.append({"questionId": question_id, "prediction": text})
with open(args.dst, "w") as f:
json.dump(all_answers, f)