Example #1
0
    print imfile

    # random block voting
    bvw = BoVW()
    bvw.load(model)
    rbv = BlockVote(
        Vote(bvw), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    votes = rbv.run(img)

    if display:
        rbv.show()

    # corase segmentation
    coarse = Votes2Img(img.shape[:2]).run(votes)

    # final segmentation
    grid = GridClassifier(MyKNN(labels, nn=nneigh), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imfile)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))
        imwrite(outfile, res)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        grid.save(outfile)
Example #2
0
    from mscr.grid import Grid, GridClassifier

    imgf, model, w, h, nn, display, save = parse_args()
    img = load_gray(imgf)

    print '#-----------------------'
    print imgf

    bvw = BoVW()
    bvw.load(model)

    ubv = BlockVote(Vote(bvw), TrivialBlockIter(w, h))
    votes = ubv.run(img)

    coarse = Votes2Img(img.shape[:2]).run(votes)

    grid = GridClassifier(MyKNN(labels, nn=nn), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imgf)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))
        imwrite(outfile, res)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        grid.save(outfile)
Example #3
0
                            "utf-8")
    ],
    format="%(asctime)s %(name)-1s -- [%(levelname)s]: %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)
vtlog = logging.getLogger("vthell_autoschedule")
console = logging.StreamHandler(sys.stdout)
console.setLevel(logging.INFO)

formatter1 = logging.Formatter("[%(asctime)s] %(message)s")
console.setFormatter(formatter1)
vtlog.addHandler(console)

vtlog.info("Collecting existing jobs...")
vthell_jobs = glob.glob(pjoin(BASE_VTHELL_PATH, "jobs", "*.json"))
vthell_jobs = [psplit(pbase(job))[0] for job in vthell_jobs]


class ValidationError(Exception):
    def __init__(self, msg):
        super().__init__(msg)


class StreamData:
    """Stream Information parser that used info like Jetri.co API
    Required schema (You can other stuff yourself.)
    {
        "id": str,
        "title": str
        "channel": str,
        "startTime": int/str
Example #4
0
    print '#------------------'
    print imfile

    # random block voting
    bvw = BoVW()
    bvw.load(model)
    rbv = BlockVote(Vote(bvw), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    votes = rbv.run(img)

    if display:
        rbv.show()

    # corase segmentation
    coarse = Votes2Img(img.shape[:2]).run(votes)

    # final segmentation
    grid = GridClassifier(MyKNN(labels, nn=nneigh), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imfile)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))
        imwrite(outfile, res)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        grid.save(outfile)
Example #5
0
    from mscr.grid import Grid, GridClassifier

    imgf, model, w, h, nn, display, save = parse_args()
    img = load_gray(imgf)

    print '#-----------------------'
    print imgf

    bvw = BoVW()
    bvw.load(model)

    ubv = BlockVote(Vote(bvw), TrivialBlockIter(w, h))
    votes = ubv.run(img)

    coarse = Votes2Img(img.shape[:2]).run(votes)

    grid = GridClassifier(MyKNN(labels, nn=nn), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imgf)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))
        imwrite(outfile, res)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        grid.save(outfile)