diff --git a/.gitignore b/.gitignore index 2de45dce8..16b740669 100644 --- a/.gitignore +++ b/.gitignore @@ -145,3 +145,9 @@ models/ *.pyc debugs/ *.c + + +# data +outputs*/ +data/* +mlruns/ \ No newline at end of file diff --git a/inference/README.md b/inference/README.md index b5e5203a1..846da1061 100644 --- a/inference/README.md +++ b/inference/README.md @@ -8,15 +8,9 @@ Additional flag can be set `--images-in-subfolders` – only images in subfolder **NOTE:** at the beggining of the script, there is `exctract_func` specified, which is used to extracy `pair_id` either from filename or from subfolder name. See the examples in the script and customize if needed. -```bash -python inference/create_embeddings.py \ ---config_file="configs/256_resnet50.yml" \ -GPU_IDS [0] \ -DATASETS.ROOT_DIR '/data/my-image-dataset/' \ -TEST.IMS_PER_BATCH 128 \ -OUTPUT_DIR 'output-dir' \ -TEST.ONLY_TEST True \ -MODEL.PRETRAIN_PATH "logs/market1501/256_resnet50/train_ctl_model/version_0/checkpoints/epoch=119.ckpt" +``` +#from repo root folder +bash test_scripts/embed.sh ``` ## Running similarity serach @@ -24,17 +18,7 @@ Example command to run similarity search using pretrained model and query images Path to images is controlled by `DATASETS.ROOT_DIR` and may be path to a single image file or to directory, which contains valid images. Additional flag can be set `--images-in-subfolders` – only images in subfolders in the `DATASETS.ROOT_DIR` will be used. -```bash -python inference/get_similar.py \ ---config_file="configs/320_resnet50_ibn_a.yml" \ ---gallery_data='output-dir' \ ---normalize_features \ ---topk=100 \ -GPU_IDS [0] \ -DATASETS.ROOT_DIR '/data/query-images/' \ -TEST.IMS_PER_BATCH 128 \ -OUTPUT_DIR 'output-dir' \ -TEST.ONLY_TEST True \ -MODEL.PRETRAIN_PATH "logs/market1501/256_resnet50/train_ctl_model/version_0/checkpoints/epoch=119.ckpt" \ -SOLVER.DISTANCE_FUNC 'cosine' +``` +#from repo root folder +bash test_scripts/similar.sh ``` \ No newline at end of file diff --git a/inference/get_similar.py b/inference/get_similar.py index c09667057..b4535264c 100644 --- a/inference/get_similar.py +++ b/inference/get_similar.py @@ -80,11 +80,12 @@ ### Build model model = CTLModel.load_from_checkpoint(cfg.MODEL.PRETRAIN_PATH) + use_cuda = True if torch.cuda.is_available() and cfg.GPU_IDS else False ### Inference log.info("Running inference") embeddings, paths = run_inference( - model, val_loader, cfg, print_freq=args.print_freq + model, val_loader, cfg, print_freq=args.print_freq, use_cuda=use_cuda ) ### Load gallery data diff --git a/test_scripts/embed.sh b/test_scripts/embed.sh new file mode 100644 index 000000000..7d70165a1 --- /dev/null +++ b/test_scripts/embed.sh @@ -0,0 +1,8 @@ +python inference/create_embeddings.py \ +--config_file="configs/256_resnet50.yml" \ +GPU_IDS [0] \ +DATASETS.ROOT_DIR 'data/ugv/' \ +TEST.IMS_PER_BATCH 8 \ +OUTPUT_DIR 'outputs/' \ +TEST.ONLY_TEST True \ +MODEL.PRETRAIN_PATH "models/market1501_resnet50_256_128_epoch_120.ckpt" \ No newline at end of file diff --git a/test_scripts/similar.sh b/test_scripts/similar.sh new file mode 100644 index 000000000..c1327d413 --- /dev/null +++ b/test_scripts/similar.sh @@ -0,0 +1,12 @@ +python inference/get_similar.py \ +--config_file="configs/256_resnet50.yml" \ +--gallery_data='outputs' \ +--normalize_features \ +--topk=100 \ +GPU_IDS [0] \ +DATASETS.ROOT_DIR 'data/ugv/' \ +TEST.IMS_PER_BATCH 128 \ +OUTPUT_DIR 'outputs' \ +TEST.ONLY_TEST True \ +MODEL.PRETRAIN_PATH "models/market1501_resnet50_256_128_epoch_120.ckpt" \ +SOLVER.DISTANCE_FUNC 'cosine' \ No newline at end of file