#🔒 image lists not working with numpy

48 messages · Page 1 of 1 (latest)

dim meteor
#
test = cv2.imread("breast-hispathology-images/8863/0/8863_idx5_x51_y1251_class0.png",cv2.IMREAD_COLOR)

resized = cv2.resize(test, (50,50), interpolation=cv2.INTER_LINEAR)

img_arrays = [[resized, 0]]
np.shape(img_arrays)

returns:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 2) + inhomogeneous part
stable sandBOT
#

@dim meteor

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

fierce pelican
#

Last line, you prob want shape of resized

dim meteor
#

its 50, 50, 3

#

(50, 50, 3)*

#

should i just do it with a np array

fierce pelican
#

I don’t get the [[resized,0]]

#

Why a list of resized and 0?

dim meteor
#

0 is the label

#

that it is non-canceroud

#

and the double list is coz its a 2D array

#

in the previous function

fierce pelican
#

So your inhomogrnous problem is that you have a list of lists with a label and an image

#

Get rid of the label

dim meteor
#

but i need the label for training

fierce pelican
#

Track it separately.

dim meteor
#

i need the URL for that

fierce pelican
#

Your data doesn’t have a consistent shape

dim meteor
#

how exactly do i map the image to the URL

fierce pelican
#

You have a list that contains elements with two different shapes, does this make sense?

#

[img, label] is a list containing elements of two different shapes.

dim meteor
#

yes

#

but the label is required

#

and from the video which i am watching they did the exact same thing and got this instead:

<string>:6: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify ‘dtype=object’ when creating the ndarray
fierce pelican
#

That’s probably old then. ‘Deprecated’ means it’ll get removed in a future version

dim meteor
#

then how do i have the image and label together?

#

while still making it make sense

fierce pelican
#

I was just explaining the problem. Maybe start ‘over’ working from the end state. What are you trying to do?

#

Im not a CV guy, I was just answering the numpy part

dim meteor
#

make a dataset of images with the labels so i can train a TF model

fierce pelican
#

(And a fresh help thread with that question might help)

dim meteor
#

ok

#

@fierce pelican should i use a np array?

fierce pelican
#

My point was: your question is about training TF. Not about images and labels

#

Start with the end problem: ‘how do I train these images using xyz, etc’

dim meteor
#

im literally gonna just do list1+list2

#

and see if it works

#

because i cant find anything online

#

AND IT WORKED

#

we did all this discusion

#

completely ignoring that list1+list 2 works

fierce pelican
#

My first recommendation was not to use numpy operations, iirc. 🙂

#

(Or not to mix Python lists and Numpy like this)

dim meteor
#

i thought it woudlnt work becaause after combining i had to use numpy operators for splitting

#

but it still did

dim meteor
#

!close

stable sandBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.