models icon indicating copy to clipboard operation
models copied to clipboard

create_pet_tf_record.py is broken

Open davidenitti opened this issue 8 years ago • 15 comments

create_pet_tf_record.py does not work anymore the flag faces_only=True does not work

There is an import error and even if I fix that, all the images are ignored: WARNING:root:Invalid example: annotations/xmls/great_pyrenees_15.xml, ignoring.

the bug should be here: mask_stack = np.stack(masks).astype(np.float32)

davidenitti avatar Dec 04 '17 18:12 davidenitti

Same issue, create_pet_tf_record.py ignores all xml files inside annotation folder and creates 2 empty pet_train_with_masks.record and pet_val_with_masks.record files.

command: python object_detection/dataset_tools/create_pet_tf_record.py --label_map_path=object_detection/data/pet_label_map.pbtxt --data_dir='pwd' --output_dir='pwd'

Output: WARNING:root:Invalid example: annotations/xmls/great_pyrenees_177.xml, ignoring.

Pls help fixing this issue.

RaymondDixon avatar Dec 05 '17 20:12 RaymondDixon

I also have this issue.

Following instructions and end with WARNING:root:Invalid example: *.xml, ignoring.

Resulting files pet_val_with_masks.record and pet_train_with_masks.record has 0 bytes size.

mencnerpavel avatar Dec 06 '17 15:12 mencnerpavel

@nealwu are you familiar with this? Who maintains this?

drpngx avatar Dec 06 '17 16:12 drpngx

You can fix this by changing the lines 160 in create_pet_tf_record.py from:

    if not faces_only:
      mask_remapped = mask_np != 2
      masks.append(mask_remapped)
    mask_stack = np.stack(masks).astype(np.float32)
    masks_flattened = np.reshape(mask_stack, [-1])

to

    if not faces_only:
      mask_remapped = mask_np != 2
      masks.append(mask_remapped)
  if not faces_only:      
    mask_stack = np.stack(masks).astype(np.float32)
    masks_flattened = np.reshape(mask_stack, [-1])

the mask stacking needs to be done outside the for loop and in an if statement

blake-varden avatar Dec 06 '17 20:12 blake-varden

Thank you, look like it solve the problem.

After suggested update TFRecords are generated as expected.

mencnerpavel avatar Dec 07 '17 09:12 mencnerpavel

same problem here and It is easy to spot and fix. I notice that there is no test case for create_pet_tf_record. Is it intentional? test case should be a good way to avoid this kind of problem.

scotthuang1989 avatar Dec 09 '17 13:12 scotthuang1989

Feel free to contribute a test case, that would be great.

On Sat, Dec 9, 2017, 5:08 AM scott huang(黄) [email protected] wrote:

same problem here and It is easy to spot and fix. I notice that there is no test case for create_pet_tf_record. Is it intentional? test case should be a good way to avoid this kind of problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/2958#issuecomment-350463518, or mute the thread https://github.com/notifications/unsubscribe-auth/AT_SbbENrscIAlEPOONkEuJb7ASiioLyks5s-oZGgaJpZM4Q1Hd4 .

drpngx avatar Dec 09 '17 19:12 drpngx

Assigning @tombstone @jch1 for object_detection.

nealwu avatar Dec 12 '17 03:12 nealwu

Does this issue solved? I still have this issue and all above tips do not work for me.

Labyrins avatar Dec 27 '17 07:12 Labyrins

@Labyrins is there any reason you un-assigned @tombstone?

nealwu avatar Dec 27 '17 19:12 nealwu

@nealwu I did not unassigned him. I just leaved my question. This issue system automatically unassigned him.

Labyrins avatar Dec 28 '17 01:12 Labyrins

I am facing the same problem. Also these lines do not exist in create_pet_tf_record.py:


if not faces_only:
      mask_remapped = mask_np != 2
      masks.append(mask_remapped)
    mask_stack = np.stack(masks).astype(np.float32)
    masks_flattened = np.reshape(mask_stack, [-1])

jashshopin avatar Apr 11 '18 07:04 jashshopin

same here @jashshopin did u solve your issue

Abduoit avatar Jun 07 '18 23:06 Abduoit

Same issue here!

GShef avatar Nov 29 '18 04:11 GShef

the problem is still there

SMA2016a avatar Dec 27 '19 07:12 SMA2016a