OFA-Sys / OFA

Official repository of OFA (ICML 2022). Paper: OFA: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence Learning Framework
Apache License 2.0
2.39k stars 248 forks source link

Update evaluate.py #441

Open JJJYmmm opened 4 months ago

JJJYmmm commented 4 months ago

Fix the conditional determination of whether the scores variable is empty.

problem

When running evaluate_refcoco.sh, encounter errors below.

scores:tensor([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
       device='cuda:0')
Traceback (most recent call last):
  File "/home/xxx/projects/OFA/run_scripts/refcoco/../../evaluate.py", line 188, in main
    if scores and isinstance(scores[0], tuple):
RuntimeError: Boolean value of Tensor with more than one value is ambiguous

Solution

            # if scores and isinstance(scores[0], tuple):
            if scores is not None and isinstance(scores[0], tuple):
                score_sum += sum([s[0] for s in scores])
                score_cnt += sum([s[1] for s in scores])