I downloaded lab files of my project of autonomous car detection , but on running it in my pc it shows error - draw has no textsize method, i replaced it then it shows floats are not subsciptable. please Help
You will need to use the same versions of all dependencies as used by Coursera environment. Please read this guide for the local machine and this for Colab.
I’m facing the same issue right now. The conflicting dependency is in the draw_boxes() function. It leverages ‘ImageDraw.textsize()’ which has been deprecated in newer Pillow package releases. It has been replaced with ‘ImageDraw.textbbox()’. I have not updated the function yet. If someone has done this. Kindly post/ share the update with me.
draw = ImageDraw.Draw(image)
label_size = draw.textsize(label, font)
#Need to identify the correct x0,y0,x1,y1 coordinates
#label_size = draw.textbbox([x0,y0,x1,y1], label, font)
@ngkhatu, @Puneet_Bajaj, @saifkhanengr
In the file relative to the root of the project where the notebook is:
./yad2k/utils/utils.py Line: 109
This code change worked for me:
#label_size = draw.textsize(label, font)
text_left, text_top, text_right, text_bottom = draw.textbbox((0,0), text=label, font=font)
label_size = (text_right - text_left, text_bottom - text_top)
Note: The origin corner (0,0) doesn’t really matters in this context because we just need the dimensions (width and height) relative to this arbitrary anchor
@Alba_Franco Thank you. This fixes it.