google / automl

Google Brain AutoML
Apache License 2.0
6.22k stars 1.45k forks source link

ERROR : 'ImageFont' object has no attribute 'getbbox' #1187

Closed abangwal closed 1 year ago

abangwal commented 1 year ago

HI i am trying to do object detection with efficientdet-d0 model using following commands and getting an error

SAVED_MODEL_DIR = 'savedmodel'
!mkdir {SAVED_MODEL_DIR}

#export saved model.
!python model_inspect.py --runmode=saved_model \
  --model_name={MODEL} --ckpt_path={CKPT_PATH} \
  --hparams="image_size=1200x650" \
  --saved_model_dir={SAVED_MODEL_DIR}

!mkdir output
!python model_inspect.py --runmode=saved_model_infer \
  --model_name=efficientdet-d0  \
  --saved_model_dir=/content/automl/efficientdet/savedmodel  \
  --input_image=/content/test.jpg --output_image_dir=/content/automl/efficientdet/output

ERROR


File "/content/automl/efficientdet/visualize/vis_utils.py", line 215, in <listcomp>
    display_str_heights = [font.getbbox(ds)[3] - font.getbbox(ds)[1] for ds in display_str_list]
AttributeError: 'ImageFont' object has no attribute 'getbbox'
andrecosta9 commented 1 year ago

Hi, I encountered the same error and after looking for the source of it I found that an upgrade of the Pillow library to version 9.5.0 fixes it. According to this link I think version 9.2.0 may also be enough. In my case, I was running the tutorial in Colab so I managed to do it by using the !pip install pillow --upgrade command.

abangwal commented 1 year ago

Hii @andrecosta9, Thanks for your reply, it has been resolved and later I decided to use TensorFlow-Hub for EfficientDet implementation. Thanks anyway. :pray: :heart: