tensorflow / models

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

object_detection model_builder_test.py fails with Python 3.x #2652

Closed radzfoto closed 7 years ago

radzfoto commented 7 years ago

System information

Describe the problem

object_detection model_builder_test.py fails with Python 3.x This appears to be a bug in Python 3.x compatibility in the object_detection/model_builder_test.py file. The code uses the following lines: Line 334: for extractor_type, extractor_class in FEATURE_EXTRACTOR_MAPS.iteritems(): Line 773: for extractor_type, extractor_class in FEATURE_EXTRACTOR_MAPS.iteritems(): In Python 3.x, dicts no longer support the attribute .iteritem(). It needs to be changed to .item(). When I changed the two lines as above, the code works fine in Python 3.6. However, for a complete solution, the code should check which Python version is being used and run the appropriate code for that version.

Here is the error log: .....EE....

ERROR: test_create_faster_rcnn_resnet_v1_models_from_config (main.ModelBuilderTest)

Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 334, in test_create_faster_rcnn_resnet_v1_models_from_config for extractor_type, extractor_class in FEATURE_EXTRACTOR_MAPS.iteritems(): AttributeError: 'dict' object has no attribute 'iteritems'

====================================================================== ERROR: test_create_rfcn_resnet_v1_model_from_config (main.ModelBuilderTest)

Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 733, in test_create_rfcn_resnet_v1_model_from_config for extractor_type, extractor_class in FEATURE_EXTRACTOR_MAPS.iteritems(): AttributeError: 'dict' object has no attribute 'iteritems'


Ran 11 tests in 0.040s

FAILED (errors=2)

fenderrex commented 7 years ago

haha funny story this error AttributeError: 'dict' object has no attribute 'iteritems' -plagued me in a live demo I built it and ran it fine I thought but after pulling my code to a different machine (at the podium ) it was failing... maybe it was the slight jump from python 3.5.x-n to 3.5.x? I found this error in the demo with python 3.5.4; the error resulting from a 0.0.x release is od I bet I was just developing under 2.7... here is where the function changes are mentioned... https://stackoverflow.com/questions/10458437/what-is-the-difference-between-dict-items-and-dict-iteritems I might make a pull request tonight :)

fenderrex commented 7 years ago

you can use my fork https://github.com/fenderrex/models until its merged. I recommend you remove the tags this was a project for someone who has used both 2.7 and 3.5 its nothing about tensorflow core concepts @radzfoto did an awesome job interpreting the error.

tombstone commented 7 years ago

@fenderrex Can you send a pull request for this ? Thank you.