taramenon
taramenon

Reputation: 43

What's causing this np.array data type error, and what's the fix?

I'm working on an image output project-- I can't figure out what the problem specific to this line is: Traceback (most recent call last):

 input_array[i].append(np.array(Image.fromarray(img_input).resize(float(g_scale), resample=Image.BICUBIC)))

TypeError: Cannot handle this data type

The "cannot handle this data type" was manually written in case an error like this happened. I searched up multiple possibilities as to the problem with the Image.fromarray line and couldn't narrow it down to this specific line's needs. Could appreciate any help!

Here's a more full view of the for loop being used, it's essentially testing the network:

  for i, gscale in enumerate(gscales):
            if float(g_scale) == 1:
                input_array[i].append(img_input)
            else:
                input_array[i].append(np.array(Image.fromarray(img_input).resize(float(g_scale), resample=Image.BICUBIC)))

            output_array[i].append(eval_model.predict_on_batch(input_array[i][-1]))

Upvotes: 0

Views: 42

Answers (1)

JaysFTW
JaysFTW

Reputation: 101

Depending on your editor, it might be because you used g_scale rather than gscale inside the for loop. It could have skipped the variable name error and instead pick up on the error from the line after else.

Upvotes: 1

Related Questions