From 972e8418bde127870906e340014d655c7da87aec Mon Sep 17 00:00:00 2001
From: iggotsul <igorgotsu@gmail.com>
Date: Fri, 11 Feb 2022 14:16:00 +0200
Subject: [PATCH] new predict

---
 Dockerfile |  1 +
 predict.py | 17 ++++++++++++-----
 run.sh     |  2 +-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index c1f0145..d5bcbfb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -55,3 +55,4 @@ RUN pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu1
 # Copy user files
 COPY --chown=1001:1001 . ${HOME_DIR}
 #CMD while true; do sleep 1; done
+
diff --git a/predict.py b/predict.py
index e4798c6..3351f8f 100644
--- a/predict.py
+++ b/predict.py
@@ -1,6 +1,7 @@
 import argparse
 import json
 import shutil
+from black import out
 import mmcv
 import os
 import os.path as osp
@@ -24,8 +25,8 @@ def parse_args():
     )
     parser.add_argument("--cfg", help="mmdetection config")
     parser.add_argument("--model", help="mmdetection model")
-    parser.add_argument("--img_dir", help="directory with test images")
-    parser.add_argument("--out", help="path to json output")
+    # parser.add_argument("--img_dir", help="directory with test images")
+    # parser.add_argument("--out", help="path to json output")
 
     args = parser.parse_args()
     return args
@@ -2902,7 +2903,7 @@ def predict(cfg_path, model_path, img_dir, out_fp):
     outputs = single_gpu_test(model, data_loader)
 
     dataset.results2json(outputs, "results")
-    shutil.move('results.segm.json', out_fp)
+    shutil.move("results.segm.json", out_fp)
 
     return outputs
 
@@ -2910,8 +2911,14 @@ def predict(cfg_path, model_path, img_dir, out_fp):
 def main():
     args = parse_args()
 
-    create_empty_json(str(args.img_dir))
-    result = predict(args.cfg, args.model, str(args.img_dir), str(args.out))
+    img_dir = os.getenv("AICROWD_TEST_IMAGES_PATH", False)
+    out_fp = os.getenv("AICROWD_PREDICTIONS_OUTPUT_PATH", False)
+
+    print(img_dir)
+    print(out_fp)
+
+    create_empty_json(img_dir)
+    result = predict(args.cfg, args.model, img_dir, out_fp)
 
 
 if __name__ == "__main__":
diff --git a/run.sh b/run.sh
index fa104c7..3a6de3e 100755
--- a/run.sh
+++ b/run.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
-python predict.py --cfg ./configs/solo.py --model ./models/epoch_20.pth --img_dir "$AICROWD_TEST_IMAGES_PATH" --out "$AICROWD_PREDICTIONS_OUTPUT_PATH"
+python predict.py --cfg ./configs/solo.py --model ./models/epoch_20.pth
 
-- 
GitLab