Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attack.py cannot reshape array of size 12544 into shape (1,3,112,112) #16

Open
ziwenlu opened this issue Oct 27, 2022 · 12 comments
Open

Comments

@ziwenlu
Copy link

ziwenlu commented Oct 27, 2022

l try to use attack.py to prepare face attack. l followed you steps and when trying to use anchor_face .it shows me that File "attack.py", line 24, in prep
return np.transpose(im, [2, 0, 1]).reshape((1, 3, 112, 112)) * 2 - 1#.reshape( [1,3,120, 120])*2-1
ValueError: cannot reshape array of size 12544 into shape (1,3,112,112). Is there something l need to set

@cacoan
Copy link

cacoan commented Oct 28, 2022

l try to use attack.py to prepare face attack. l followed you steps and when trying to use anchor_face .it shows me that File "attack.py", line 24, in prep return np.transpose(im, [2, 0, 1]).reshape((1, 3, 112, 112)) * 2 - 1#.reshape( [1,3,120, 120])*2-1 ValueError: cannot reshape array of size 12544 into shape (1,3,112,112). Is there something l need to set

Have you solved it, please? I also had this issue, but I added the parameter'channel_axis=2' and 12544 became 50176.

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

l don't solve it and do you have any ideas

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

which line do you add the channel_axis=2?

@cacoan
Copy link

cacoan commented Oct 28, 2022 via email

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

l found my problem is the shape of image is(112,112,1)
image
However l use the image input is(600,600,3)

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

and my tensorflow version is 1.14.0 with numpy 1.19.2

@cacoan
Copy link

cacoan commented Oct 28, 2022 via email

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

it seems not work as well

@cacoan
Copy link

cacoan commented Oct 28, 2022 via email

@ziwenlu
Copy link
Author

ziwenlu commented Oct 28, 2022

so have you already manage to solve them?

@cacoan
Copy link

cacoan commented Oct 29, 2022

那么你已经设法解决它们了吗?

no

@hust-lizewei
Copy link

This problem is because your version of scikit-image is too high, when using the rescale function, it reads not an RGB image but a grayscale map, the solution is simple, either reduce the scikit-image version or replace the rescale function:
pip install scikit-image==0.14.2 -i https://mirrors.aliyun.com/pypi/simple/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants