ValueError could not broadcast input array from shape 224 224 9 into shape 224 224

0 votes
img_shape = 224

test_data = []

test_labels = []


for select in ['/Covid_19/','/Normal/', '/Pneumonia/']:

  for img in (os.listdir(test_path + select)):

    img = plt.imread(test_path + select + img, 0)

    img = cv2.resize(img, (img_shape, img_shape))

    img = np.dstack([img, img, img])

    img = img.astype('float32') / 255

    if select =='/Covid_19/':

      label = 0

    elif select=='/Normal/':

      label = 1

    elif select=='/Pneuminia/':

      label = 2

    test_data.append(img)

    test_labels.append(label)


test_data = np.array(test_data)

test_labels = np.array(test_labels)

--------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-fcf0539110b5> in <module>()
     18     test_labels.append(label)
     19 
---> 20 test_data = np.array(test_data)
     21 test_labels = np.array(test_labels)

ValueError: could not broadcast input array from shape (224,224,9) into shape (224,224)
Nov 6, 2020 in Python by Eyosiyas
• 120 points
1,564 views

Hey, @Eyoslyas,

 You can try to convert all the png's to greyscale and set c_dim=1 and it works.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer
+1 vote
0 answers

ValueError: could not broadcast input array from shape (2) into shape (5)

I was implementing gillespie algorithm and when ...READ MORE

Dec 23, 2019 in Python by anonymous
• 130 points

reshown Jan 13, 2020 by Kalgi 3,854 views
0 votes
1 answer

ValueError: could not broadcast input array from shape (4,1) into shape (4)

Hey @Giorgio, You can try this hope this ...READ MORE

answered Feb 18, 2020 in Python by Gitika
• 65,890 points
10,170 views
0 votes
1 answer

ValueError: could not broadcast input array from shape (360,270,3) into shape (360,280,3)

Hi@akhtar, In the above error it shows could not ...READ MORE

answered Apr 9, 2020 in Python by MD
• 95,460 points
20,357 views
+1 vote
0 answers

ValueError: operands could not be broadcast together with shapes (3,) (1000,)

This is the part of my code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 6,170 views
+1 vote
5 answers
0 votes
0 answers

Operands Could not be Broadcast with Shapes (19,)(0,) — KNN

I am working on how to use ...READ MORE

Nov 10, 2019 in Python by sam
• 120 points
1,070 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP