(directory, name)
return image_data, shape, bboxes, labels, labels_text, difficult, truncated
Process a image and annotation file.

    Args:
      filename: string, path to an image file e.g., '/path/to/example.JPG'.
      coder: instance of ImageCoder to provide TensorFlow image coding utils.
    Returns:
      image_buffer: string, JPEG encoding of RGB image.
      height: integer, image height in pixels.
      width: integer, image width in pixels.
Process a image and annotation file.
Process a image and annotation file .
def _process_image(directory, name):
    """Process a image and annotation file.

    Args:
      filename: string, path to an image file e.g., '/path/to/example.JPG'.
      coder: instance of ImageCoder to provide TensorFlow image coding utils.
    Returns:
      image_buffer: string, JPEG encoding of RGB image.
      height: integer, image height in pixels.
      width: integer, image width in pixels.
    """
    # Read the image file.
    filename = os.path.join(directory, DIRECTORY_IMAGES, name + '.jpg')
    #filename = directory + DIRECTORY_IMAGES + name + '.jpg'
    image_data = tf.gfile.FastGFile(filename, 'rb').read()

    # Read the XML annotation file.
    filename = os.path.join(directory, DIRECTORY_ANNOTATIONS, name + '.xml')
    tree = ET.parse(filename)
    root = tree.getroot()

    # Image shape.
    size = root.find('size')
    shape = [int(size.find('height').text),
             int(size.find('width').text),
             int(size.find('depth').text)]
    # Find annotations.
    bboxes = []
    labels = []
    labels_text = []
    difficult = []
    truncated = []
    for obj in root.findall('object'):
        label = obj.find('name').text
        labels.append(int(VOC_LABELS[label][0]))
        labels_text.append(label.encode('ascii'))

        isdifficult = obj.find('difficult')
        if isdifficult is not None:
            #print('ddd')
            difficult.append(int(isdifficult.text))
        else:
            difficult.append(0)

        istruncated = obj.find('truncated')
        if istruncated is not None:
            truncated.append(int(istruncated.text))
        else:
            truncated.append(0)
        # if obj.find('difficult'):
        #     difficult.append(int(obj.find('difficult').text))
        # else:
        #     difficult.append(0)
        # if obj.find('truncated'):
        #     truncated.append(int(obj.find('truncated').text))
        # else:
        #     truncated.append(0)

        bbox = obj.find('bndbox')
        bboxes.append((float(bbox.find('ymin').text) / shape[0],
                       float(bbox.find('xmin').text) / shape[1],
                       float(bbox.find('ymax').text) / shape[0],
                       float(bbox.find('xmax').text) / shape[1]
                       ))
    return image_data, shape, bboxes, labels, labels_text, difficult, truncated
def _process_image ( directory , name ) : # Read the image file. filename = os . path . join ( directory , DIRECTORY_IMAGES , name + '.jpg' ) #filename = directory + DIRECTORY_IMAGES + name + '.jpg' image_data = tf . gfile . FastGFile ( filename , 'rb' ) . read ( ) # Read the XML annotation file. filename = os . path . join ( directory , DIRECTORY_ANNOTATIONS , name + '.xml' ) tree = ET . parse ( filename ) root = tree . getroot ( ) # Image shape. size = root . find ( 'size' ) shape = [ int ( size . find ( 'height' ) . text ) , int ( size . find ( 'width' ) . text ) , int ( size . find ( 'depth' ) . text ) ] # Find annotations. bboxes = [ ] labels = [ ] labels_text = [ ] difficult = [ ] truncated = [ ] for obj in root . findall ( 'object' ) : label = obj . find ( 'name' ) . text labels . append ( int ( VOC_LABELS [ label ] [ 0 ] ) ) labels_text . append ( label . encode ( 'ascii' ) ) isdifficult = obj . find ( 'difficult' ) if isdifficult is not None : #print('ddd') difficult . append ( int ( isdifficult . text ) ) else : difficult . append ( 0 ) istruncated = obj . find ( 'truncated' ) if istruncated is not None : truncated . append ( int ( istruncated . text ) ) else : truncated . append ( 0 ) # if obj.find('difficult'): #     difficult.append(int(obj.find('difficult').text)) # else: #     difficult.append(0) # if obj.find('truncated'): #     truncated.append(int(obj.find('truncated').text)) # else: #     truncated.append(0) bbox = obj . find ( 'bndbox' ) bboxes . append ( ( float ( bbox . find ( 'ymin' ) . text ) / shape [ 0 ] , float ( bbox . find ( 'xmin' ) . text ) / shape [ 1 ] , float ( bbox . find ( 'ymax' ) . text ) / shape [ 0 ] , float ( bbox . find ( 'xmax' ) . text ) / shape [ 1 ] ) ) return image_data , shape , bboxes , labels , labels_text , difficult , truncated