seanbell / intrinsic

Code for Bell et al, "Intrinsic Images in the Wild", SIGGRAPH 2014.
MIT License
152 stars 33 forks source link

ValueError: output array is read-only #5

Open yuxijin opened 5 years ago

yuxijin commented 5 years ago

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?

seanbell commented 5 years ago

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)
yuxijin commented 5 years ago

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

On Sat, Jun 1, 2019 at 1:00 AM Sean Bell notifications@github.com 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 .

seanbell commented 5 years ago

Did this solve your issue?

yuxijin commented 5 years ago

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 notifications@github.com 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 .