0

so I return (N.B. self.name is %s, others %f)

return np.array([self.name, self.x1_hand, self.y1_hand, self.x2_hand, self.y2_hand, self.x1_obj, self.y1_obj, self.x2_hand, self.x2_obj])

and if variable exists I append, if not I set that one as [0] (making array of arrays) temp is the array returned (the one above)

            if 'array' in locals():
                print(array)
                print(temp)
                array = np.append(array,temp)
            else:
                array = temp

after some data processing, I get an array shape (1188,) which I need to save to a file

['61255/0014.jpg' '0' '193.7876340493057' ... '86.83602771362587' '147.85219399538107' '240.13856812933022'] ['47350/0024.jpg' '90.4849884526559' '81.20092378752885' '134.54965357967666' '114.73441108545035' '215.05773672055426' '87.02078521939954' '134.54965357967666' '262.5866050808314'] ['61255/0014.jpg' '0' '193.7876340493057' '152.51979991070488' '239.04912287258873']

as

name x1 y1 x2 y2 x1' y1' x2' y2'
name x1 y1 x2 y2 x1' y1' x2' y2'
name x1 y1 x2 y2 x1' y1' x2' y2'

for instance: (shape: (8,1))

61255/0014.jpg 0 193.7876340493057 ... 86.83602771362587 147.85219399538107 240.13856812933022

I struggle getting the array in right format, saving because it is a mix of data, getting an error back saying format doesn't match, also I need to make a row out of an array. How should I approach this?

1

1 Answer 1

0
            if 'array' in locals():
                array = np.append(array,temp, axis=0)
            else:
                array = temp

The code was missing the keyword and that is 'axis=0', where it defines in what axis the line has to be added.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.