Skip to content

Commit

Permalink
a better fix (no validators)
Browse files Browse the repository at this point in the history
  • Loading branch information
cad0p committed Jul 8, 2019
1 parent 40f32aa commit 3a3f367
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions maskrcnn_modanet/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def save():
pass

@view.command()
@click.option('-p', '--proc-img-path', callback=validators.check_if_image_exists_in_dataset)
@click.option('-p', '--proc-img-path')
@click.option('-u', '--proc-img-url', callback=validators.check_if_url_downloadable)
@click.option('-s', '--segments', is_flag=True, default=False, help='For every annotation found in the image')
@click.option('-a', '--all-set', is_flag=True, default=False, help='Results for each image in the validation set')
Expand All @@ -258,7 +258,7 @@ def image(ctx, proc_img_path, proc_img_url, segments, all_set, model_path, thres
print_help(ctx, None, value=True)

@view.command()
@click.option('-p', '--proc-img-path', callback=validators.check_if_image_exists_in_dataset)
@click.option('-p', '--proc-img-path')
@click.option('-u', '--proc-img-url', callback=validators.check_if_url_downloadable)
@click.option('-mt', '--model-type', default='default', callback=validators.check_if_model_type_valid, help='Set \'trained\' for your last trained snapshot on the snapshots folder, \'coco\' for the image recognition of the COCO dataset. \'default\' is the default value and is the pretrained modanet snapshot you downloaded in the results folder.')
@click.option('-m', '--model-path', default=None, callback=validators.check_if_file_exists, help='If you want to use a custom model other than the best one found in results')
Expand All @@ -276,7 +276,7 @@ def annotations(ctx, proc_img_path, proc_img_url, model_path, threshold_score, m


@save.command()
@click.option('-p', '--proc-img-path', callback=validators.check_if_image_exists_in_dataset)
@click.option('-p', '--proc-img-path')
@click.option('-u', '--proc-img-url', callback=validators.check_if_url_downloadable)
@click.option('-s', '--segments', is_flag=True, default=False, help='For every annotation found in the image')
@click.option('-a', '--all-set', is_flag=True, default=False, help='Results for each image in the validation set')
Expand All @@ -297,7 +297,7 @@ def image(ctx, proc_img_path, proc_img_url, save_path, segments, all_set, model_
print_help(ctx, None, value=True)

@save.command()
@click.option('-p', '--proc-img-path', callback=validators.check_if_image_exists_in_dataset)
@click.option('-p', '--proc-img-path')
@click.option('-u', '--proc-img-url', callback=validators.check_if_url_downloadable)
@click.option('-mt', '--model-type', default='default', callback=validators.check_if_model_type_valid, help='Set \'trained\' for your last trained snapshot on the snapshots folder, \'coco\' for the image recognition of the COCO dataset. \'default\' is the default value and is the pretrained modanet snapshot you downloaded in the results folder.')
@click.option('-m', '--model-path', default=None, callback=validators.check_if_file_exists, help='If you want to use a custom model other than the best one found in results')
Expand Down
8 changes: 7 additions & 1 deletion maskrcnn_modanet/processimages.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ def main(proc_img_path=None, proc_img_url=None, all_set=True, save_path=None, mo
# use this environment flag to change which GPU to use
#os.environ["CUDA_VISIBLE_DEVICES"] = "1"

with open(os.path.expanduser('~')+ '/.maskrcnn-modanet/' + 'savedvars.json') as f:
savedvars = json.load(f)
path = savedvars['datapath']

img_path = path + "datasets/coco/images/"

if not model:
# set the modified tf session as backend in keras
keras.backend.tensorflow_backend.set_session(get_session())
Expand Down Expand Up @@ -205,7 +211,7 @@ def extract_number(f):

elif proc_img_path:
# just draw the image selected
images = [{'file_name': proc_img_path}]
images = [{'file_name': img_path + proc_img_path if os.path.abspath(proc_img_path) != proc_img_path else proc_img_path}]
elif proc_img_url:
# just draw the image selected
images = [{'file_name': proc_img_url}]
Expand Down

0 comments on commit 3a3f367

Please sign in to comment.