intrinsic icon indicating copy to clipboard operation
intrinsic copied to clipboard

ValueError: output array is read-only

Open yuxijin opened this issue 6 years ago • 4 comments

Hi, guys. I was attempting to run the decompose.py file by command 'python decompose.py test.jpg', while I got an error like the following: Traceback (most recent call last): File "decompose.py", line 125, in <module> r, s, decomposition = solver.solve() File "/home/jinyuxi/Documents/intrinsic/bell2014/solver.py", line 38, in solve self.initialize_intensities() File "/home/jinyuxi/Documents/intrinsic/bell2014/solver.py", line 105, in initialize_intensities samples[:, 0] *= self.params.kmeans_intensity_scale ValueError: output array is read-only I don't know why and how to fix this issue. Is there anybody can tell me what should I do?

yuxijin avatar May 31 '19 10:05 yuxijin

Not sure why it isn't letting you modify -- looks like the array is not writeable. You could try changing the code to add this line before the error: samples = np.copy(samples)

If that works, then a more general solution might be this code instead:

if not samples.flags['WRITEABLE']):
    samples = np.copy(samples)

seanbell avatar May 31 '19 17:05 seanbell

Thank for your suggestion, I'll try it later.

On Sat, Jun 1, 2019 at 1:00 AM Sean Bell [email protected] wrote:

Not sure why it isn't letting you modify -- looks like the array is not writeable. You could try changing the code to add this line before the error: samples = np.copy(samples)

If that works, then a more general solution might be this code instead:

if not samples.flags['WRITEABLE']): samples = np.copy(samples)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seanbell/intrinsic/issues/5?email_source=notifications&email_token=AKILRP6CT77UC7U2REC5KVDPYFKTNA5CNFSM4HRYOPIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWVZTKY#issuecomment-497785259, or mute the thread https://github.com/notifications/unsubscribe-auth/AKILRPYTK5RGQZ2HDTUZQDTPYFKTNANCNFSM4HRYOPIA .

yuxijin avatar Jun 03 '19 04:06 yuxijin

Did this solve your issue?

seanbell avatar Jun 15 '19 16:06 seanbell

Yeah, it has solved the issue. Thank you very much! And I am sorry for replying your email after so long. I was busy with other things.

Have a nice day!

Yuxi

On Sun, Jun 16, 2019 at 12:32 AM Sean Bell [email protected] wrote:

Did this solve your issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seanbell/intrinsic/issues/5?email_source=notifications&email_token=AKILRP45XC3XPSLVA2LLEJDP2UKRJA5CNFSM4HRYOPIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXY3RIY#issuecomment-502380707, or mute the thread https://github.com/notifications/unsubscribe-auth/AKILRP5ACV5RN5U42GLOJATP2UKRJANCNFSM4HRYOPIA .

yuxijin avatar Jul 05 '19 05:07 yuxijin