DriveLM icon indicating copy to clipboard operation
DriveLM copied to clipboard

ValueError in evaluation.py, the answer got from infer has a wrong number.

Open piqiuni opened this issue 1 year ago • 6 comments

Running evaluation.py with error:

File "evaluation.py", line 93, in match_result
    answer_nums = np.array([list(map(float, x.split()))[0] for x in answer_nums]).reshape(-1, 2)
ValueError: cannot reshape array of size 13 into shape (2)

The accurate answer format should be [880.0, 500.0, 1000.0, 500.0, 1000.0, 500.0] and reshape to [[ 880. 500.], [1000. 500.], [1000. 500.]] But I got a [1055.5, 510.0, 1055.5, 510.0, 1055.5, 510.0, 1055.5, 510.0, 1055.5, 510.0, 1055.5, 510.0, 1055.5] with 13 numbers in my answer.

I have no idea why it happens. Please help

piqiuni avatar Apr 08 '24 16:04 piqiuni

You could employ post-processing techniques, such as rule-based methods, to address this situation. For instance, you could opt to retain only the initial 12 numbers. Subsequently, you could proceed with evaluating your answers.

DevLinyan avatar Apr 09 '24 05:04 DevLinyan

@DevLinyan Thanks for the reply.

I still have doubts about the cause of this error. According to your reply, this error is not due to a model inference error, but due to a bug in the evaluation code? So I can just crop and remove the excess data (the 13th)?

piqiuni avatar Apr 09 '24 15:04 piqiuni

Same issues answer_nums = np.array([list(map(float, x.split()))[0] for x in answer_nums]).reshape(-1, 2) ValueError: cannot reshape array of size 5 into shape (2) will this happen is the test server?

hutslib avatar Apr 10 '24 09:04 hutslib

The error you're encountering is actually caused by your own model. Typically, the model should produce the even number as output.

DevLinyan avatar Apr 10 '24 10:04 DevLinyan

For those who have the same iisues. It seems that answer_nums = re.findall(r'\d+\.\d+', answer) retrieve data in \d+.\d format but some of my answers are in \d format.

hutslib avatar Apr 10 '24 11:04 hutslib

We checked again and find the error caused by the aborted answer of the LLM:

answer= "There is a black sedan to the front of the ego vehicle, a black sedan to the back of the ego vehicle, a black sedan to the front of the ego vehicle, a black sedan to the back of the ego vehicle, a black sedan to the front of the ego vehicle, a black sedan to the back of the ego vehicle, and a black sedan to the front of the ego vehicle. The IDs of these objects are <c1,CAM_FRONT,1055.5,500.0>, <c2,CAM_BACK,1055.5,500.0>, <c3,CAM_FRONT,1055.5,500.0>, <c4,CAM_BACK,1055.5,500.0>, <c5,CAM_FRONT,1055.5,500.0>, <c6,CAM_BACK,1055.5,500.0>, and <c7,CAM_FRONT,1055.5,500"
GT= [1055.5, 500.0, 1055.5, 500.0, 1055.5, 500.0, 1055.5, 500.0, 1055.5, 500.0, 1055.5, 500.0, 1055.5]
answer_nums = re.findall(r'\d+\.\d+', answer)
GT_nums = re.findall(r'\d+\.\d+', GT)

where the answer stoped at , and <c7,CAM_FRONT,1055.5,500, and the next two lines of code is to contract float numbers.

And if you just submit the answer toserver, it will cause the same error So, before the evaluation, you should deal with the answers with none even numbers, to cut it to a even numbers santence,

piqiuni avatar Apr 15 '24 12:04 piqiuni