Yushi-Hu / tifa

TIFA: Accurate and Interpretable Text-to-Image Faithfulness Evaluation with Question Answering
https://tifa-benchmark.github.io/
Apache License 2.0
129 stars 7 forks source link

Errors in dictionary handling #5

Open TangMohan opened 3 months ago

TangMohan commented 3 months ago

In the function tifa_score_single, there are these lines:

        if question_answer_pair['question'] not in question_logs:
            question_logs[question_answer_pair['question']] = question_answer_pair
        choices=question_answer_pair['choices']

Consider changing this to:

        if question_answer_pair['question'] not in question_logs:
            question_logs[question_answer_pair['question']] = copy.deepcopy(question_answer_pair)
        choices=question_answer_pair['choices']

Otherwise, whenever you run result = tifa_score_single(vqa_model, filtered_questions, img_path) you are changing the original filtered_questions, and result contain a reference to filtered_questions. Wierd things would happen. For example, if you make a new call with the same filtered_questions, the result from the previous call would be changed.