コード例 #1
0
def show_hough_image(ibs, gid, species=None, fnum=None, **kwargs):
    if fnum is None:
        fnum = pt.next_fnum()
    title = 'Hough Image: ' + vh.get_image_titles(ibs, gid)
    print(title)

    if species is None:
        species = ibs.get_
        #.cfg.detect_cfg.species_text
    src_gpath_list = ibs.get_image_detectpaths([gid])
    dst_gpath_list = [splitext(gpath)[0] for gpath in src_gpath_list]
    hough_gpath_list = [
        gpath + '_' + species + '_hough.png' for gpath in dst_gpath_list
    ]
    # Detect with hough
    config = {
        'output_gpath_list': hough_gpath_list,
    }
    print('-' * 80)
    print('')
    print('WARNING!!!')
    print('Hough image is not used often and not worth putting into depcache.')
    print('This image is computed as needed and not cached to disk.')
    print('')
    print('-' * 80)
    results_list = list(
        randomforest.detect_gpath_list_with_species(  # NOQA
            ibs, src_gpath_list, species, **config))
    # Get path
    hough_gpath = hough_gpath_list[0]
    img = vt.imread(hough_gpath)
    fig, ax = viz_image2.show_image(img, title=title, fnum=fnum, **kwargs)
    return fig, ax
コード例 #2
0
ファイル: viz_hough.py プロジェクト: Erotemic/ibeis
def show_hough_image(ibs, gid, species=None, fnum=None, **kwargs):
    if fnum is None:
        fnum = pt.next_fnum()
    title = 'Hough Image: ' + vh.get_image_titles(ibs, gid)
    print(title)

    if species is None:
        species = ibs.cfg.detect_cfg.species_text
    src_gpath_list = ibs.get_image_detectpaths([gid])
    dst_gpath_list = [splitext(gpath)[0] for gpath in src_gpath_list]
    hough_gpath_list = [gpath + '_' + species + '_hough.png' for gpath in dst_gpath_list]
    # Detect with hough
    config = {
        'output_gpath_list': hough_gpath_list,
    }
    print('-' * 80)
    print('')
    print('WARNING!!!')
    print('Hough image is not used often and not worth putting into depcache.')
    print('This image is computed as needed and not cached to disk.')
    print('')
    print('-' * 80)
    results_list = list(randomforest.detect_gpath_list_with_species(ibs, src_gpath_list, species, **config))  # NOQA
    # Get path
    hough_gpath = hough_gpath_list[0]
    img = vt.imread(hough_gpath)
    fig, ax = viz_image2.show_image(img, title=title, fnum=fnum, **kwargs)
    return fig, ax
コード例 #3
0
ファイル: preproc_probchip.py プロジェクト: whaozl/ibeis
def write_dirty_aids(ibs, dirty_probchip_fpath_list, dirty_aids, config2_,
                     species):
    if config2_ is None:
        fw_detector = ibs.cfg.featweight_cfg.fw_detector
    else:
        fw_detector = config2_.get('fw_detector')

    if fw_detector == 'rf':
        (
            extramargin_fpath_list,
            probchip_extramargin_fpath_list,
            halfoffset_cs_list,
        ) = compute_extramargin_detectchip(ibs,
                                           dirty_aids,
                                           config2_=config2_,
                                           species=species,
                                           FACTOR=4)
        #dirty_cfpath_list  = ibs.get_annot_chip_fpath(dirty_aids, ensure=True, config2_=config2_)

        config = {
            'scale_list': [1.0],
            'output_gpath_list': probchip_extramargin_fpath_list,
            'mode': 1,
        }
        probchip_generator = randomforest.detect_gpath_list_with_species(
            ibs, extramargin_fpath_list, species, **config)
        # Evalutate genrator until completion
        ut.evaluate_generator(probchip_generator)
        extramargin_mask_gen = (vt.imread(fpath, grayscale=True)
                                for fpath in probchip_extramargin_fpath_list)
        # Crop the extra margin off of the new probchips
        _iter = zip(dirty_probchip_fpath_list, extramargin_mask_gen,
                    halfoffset_cs_list)
        for (probchip_fpath, extramargin_probchip, halfmargin) in _iter:
            half_w, half_h = halfmargin
            probchip = extramargin_probchip[half_h:-half_h, half_w:-half_w]
            vt.imwrite(probchip_fpath, probchip)
    elif fw_detector == 'cnn':
        # dont use extrmargin here (for now)
        chip_fpath_list = ibs.get_annot_chip_fpath(dirty_aids,
                                                   config2_=config2_)
        mask_gen = ibs.generate_species_background_mask(
            chip_fpath_list, species)
        _iter = zip(dirty_probchip_fpath_list, mask_gen)
        for chunk in ut.ichunks(_iter, 64):
            for probchip_fpath, probchip in ut.ProgressIter(
                    chunk,
                    lbl='write probchip chunk',
                    adjust=True,
                    time_thresh=30.0):
                probchip = postprocess_mask(probchip)
                vt.imwrite(probchip_fpath, probchip)
    else:
        raise NotImplementedError('bad fw_detector=%r' % (fw_detector, ))
コード例 #4
0
ファイル: preproc_probchip.py プロジェクト: heroinlin/ibeis
def write_dirty_aids(ibs, dirty_probchip_fpath_list, dirty_aids, config2_, species):
    if config2_ is None:
        featweight_detector = ibs.cfg.featweight_cfg.featweight_detector
    else:
        featweight_detector = config2_.get('featweight_detector')

    if featweight_detector == 'rf':
        (extramargin_fpath_list,
         probchip_extramargin_fpath_list,
         halfoffset_cs_list,
         ) = compute_extramargin_detectchip(
             ibs, dirty_aids, config2_=config2_, species=species, FACTOR=4)
        #dirty_cfpath_list  = ibs.get_annot_chip_fpath(dirty_aids, ensure=True, config2_=config2_)

        config = {
            'scale_list': [1.0],
            'output_gpath_list': probchip_extramargin_fpath_list,
            'mode': 1,
        }
        probchip_generator = randomforest.detect_gpath_list_with_species(
            ibs, extramargin_fpath_list, species, **config)
        # Evalutate genrator until completion
        ut.evaluate_generator(probchip_generator)
        extramargin_mask_gen = (
            vt.imread(fpath, grayscale=True) for fpath in probchip_extramargin_fpath_list
        )
        # Crop the extra margin off of the new probchips
        _iter = zip(dirty_probchip_fpath_list,
                    extramargin_mask_gen,
                    halfoffset_cs_list)
        for (probchip_fpath, extramargin_probchip, halfmargin) in _iter:
            half_w, half_h = halfmargin
            probchip = extramargin_probchip[half_h:-half_h, half_w:-half_w]
            vt.imwrite(probchip_fpath, probchip)
    elif featweight_detector == 'cnn':
        # dont use extrmargin here (for now)
        chip_fpath_list = ibs.get_annot_chip_fpath(dirty_aids, config2_=config2_)
        mask_gen = ibs.generate_species_background_mask(chip_fpath_list, species)
        _iter = zip(dirty_probchip_fpath_list, mask_gen)
        for chunk in ut.ichunks(_iter, 64):
            for probchip_fpath, probchip in ut.ProgressIter(chunk, lbl='write probchip chunk', adjust=True, time_thresh=30.0):
                probchip = postprocess_mask(probchip)
                vt.imwrite(probchip_fpath, probchip)
    else:
        raise NotImplementedError('bad featweight_detector=%r' % (featweight_detector,))
コード例 #5
0
ファイル: viz_hough.py プロジェクト: heroinlin/ibeis
def show_hough_image(ibs, gid, species=None, fnum=None, **kwargs):
    if fnum is None:
        fnum = pt.next_fnum()
    title = 'Hough Image: ' + vh.get_image_titles(ibs, gid)
    print(title)

    if species is None:
        species = ibs.cfg.detect_cfg.species_text
    src_gpath_list = ibs.get_image_detectpaths([gid])
    dst_gpath_list = [splitext(gpath)[0] for gpath in src_gpath_list]
    hough_gpath_list = [gpath + '_' + species + '_hough.png' for gpath in dst_gpath_list]
    # Detect with hough
    config = {
        'output_gpath_list': hough_gpath_list,
    }
    results_list = list(randomforest.detect_gpath_list_with_species(ibs, src_gpath_list, species, **config))  # NOQA
    # Get path
    hough_gpath = hough_gpath_list[0]
    img = gtool.imread(hough_gpath)
    fig, ax = viz_image2.show_image(img, title=title, fnum=fnum, **kwargs)
    return fig, ax