-
Notifications
You must be signed in to change notification settings - Fork 50
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
nail.py code. TypeError, IndexError #1
Comments
Hello HyunmokMoon, I'm trying to make lipstick.py work. I have same error as you had with nail.py. I followed your advice and changed to int type, but still got the error: Traceback (most recent call last): Any new advice on how to make it work?? I'm new to python and can't step over this error. Here is my modified code: x = [] #will contain the x coordinates of points on lips int_x = map(int,x) def ext(a,b,i): for i in range(int(o_u_l[1][0]),int(i_u_l[1][0]+1)): for i in range(int(i_u_l[1][0]),int(o_u_l[1][-1]+1)): for i in range(int(i_u_r[1][-1]),int(o_u_r[1][-1]+1)): for i in range(int(i_u_r[1][0]),int(i_u_r[1][-1]+1)): val = color.rgb2lab((im[int_x,int_y]/255.).reshape(len(int_x),1,3)).reshape(len(int_x),3) im[int_x,int_y] = color.lab2rgb(val.reshape(len(int_x),1,3)).reshape(len(int_x),3)*255 Many thanks!! |
Problem solved. Was my bad : int_x and int_y moved after x and y took the values: x = [] def ext(a,b,i): int_x = map(int,x) |
hello @antonov7 i tried your suggested solution but it doesnt work for me |
Yes, this is not working for me either. @antonov7 - any other suggestions? |
Hi,
in nail.py I've got this error. TypeError and IndexError.
$ python nail.py
Traceback (most recent call last):
File "nail.py", line 61, in
x, y = getInteriorPoints(x, y)
File "nail.py", line 30, in getInteriorPoints
ext(amin(ylist), amax(ylist), i)
File "nail.py", line 24, in ext
naily.extend((ones(b-a)*i).tolist())
File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py", line 192, in ones
a = empty(shape, dtype, order)
TypeError: 'float' object cannot be interpreted as an index
I resolved this line change.
#a, b=round(a), round(b)
a = int (round(a))
b = int (round(b))
After that, I also got error message. IndexError.
Traceback (most recent call last):
File "nail.py", line 65, in
applyTexture(x, y)
File "nail.py", line 52, in applyTexture
val2 = color.rgb2lab((im[x, y]/255.).reshape(len(x), 1, 3)).reshape(len(x), 3)
IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indicesI resolved by int value.
apply x list to int type.
change to int type
int_x = map(int,x)
int_y = map(int,y)
and use int_x lather than x, int_y lather than y.
val2 = color.rgb2lab((im[int_x, int_y]/255.).reshape(len(int_x), 1, 3)).reshape(len(int_x), 3)
this line also replaced.
x substituted by int_x and y by int_y
im[int_x, int_y] = color.lab2rgb(val2.reshape(len(int_x), 1, 3)).reshape(len(int_x), 3)*255
then I can see result image.
in Ubuntu 16.10
python 2.7
blush.py is ok. but lipstick.py is also same issue. Maybe this change also could be applied to lipstick.py file.
I share for others.
Thank you.
in python 3 map function have to change little bit different way.
http://stackoverflow.com/questions/7368789/convert-all-strings-in-a-list-to-int
The text was updated successfully, but these errors were encountered: