tensorflow / models

Models and examples built with TensorFlow
Other
77.16k stars 45.75k forks source link

FutureWarning Issued by create_pet_tf_record.py #4512

Closed WillAyd closed 6 years ago

WillAyd commented 6 years ago

When following through the instructions in models/research/object_detection/g3doc/running_pets.md the python script generates a FutureWarning from lxml:

/Users/williamayd/clones/models/research/object_detection/utils/dataset_util.py:75: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
  if not xml:

The offending line is below and the FutureWarning should be easily resolved if replace with the more explicit len(xml):

https://github.com/tensorflow/models/blob/29c9f9855711006704b8fa9364f966d67694287e/research/object_detection/utils/dataset_util.py#L75

I would be happy to submit a PR to clean this up

System information

Describe the problem

The xml parsing code issues a warning from lxml for the boolean check it performs to detect whether or not there are child elements. If lxml changes this behavior in the future this code will break.

Source code / logs

Provided again for reference. Here is the offending line:

https://github.com/tensorflow/models/blob/29c9f9855711006704b8fa9364f966d67694287e/research/object_detection/utils/dataset_util.py#L75

And the warning that it generates:

/Users/williamayd/clones/models/research/object_detection/utils/dataset_util.py:75: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
  if not xml:
pkulzc commented 6 years ago

@WillAyd Thanks for noticing this! If you would like to, please simply send a PR to fix this and I'll review and merge it.

pkulzc commented 6 years ago

Thanks for the fix!