Iammuratc / satellitepy

Fine-grained object detection in satellite images
MIT License
2 stars 0 forks source link

Testing trained model fails with tools/test/bbavector/test_patch.py #193

Open bobbender opened 5 months ago

bobbender commented 5 months ago

I managed setup the environment and install satellitepy following your instructions and it works fine.

I successfully trained a test model with my custom dataset with the following command:

python3 tools/train/bbavector.py \
--train-image-folder /satellitepy/data/small_1024/train/images/  \
--train-label-folder /satellitepy/data/small_1024/train/annfiles/ \
--train-label-format dota \
--valid-image-folder /satellitepy/data/small_1024/val/images/ \
--valid-label-folder  /satellitepy/data/small_1024/val/annfiles/ \
--valid-label-format dota \
--tasks coarse-class \
--target-task coarse-class \
--input-h 1024 \
--input-w 1024 \
--out-folder /mount_dir/training/ \
--num-epoch 1

When I try to test is with the following command:

python3 tools/test/bbavector/test_patch.py \
--weights-path /mount_dir/training/model_best.pth \
--input-h 1024 \
--input-w 1024 \
--in-image-folder /satellitepy/data/small_1024/train/images/ \
--in-label-folder /satellitepy/data/small_1024/train/annfiles/ \
--in-label-format dota \
--tasks coarse-class \
--out-folder /mount_dir/eval/

I get an error:

ERROS:
Traceback (most recent call last):
  File "tools/test/bbavector/test_patch.py", line 103, in <module>
    main(args)
  File "tools/test/bbavector/test_patch.py", line 50, in main
    log_path = get_default_log_path(Path(__file__).resolve().stem) if args.log_path is None else Path(args.log_path)
AttributeError: 'Namespace' object has no attribute 'log_path'

I assume there is an arg param missing in the file "tools/test/bbavector/test_patch.py", something like this (?): parser.add_argument('--log-path', type=Path, required=False, help='Log path.')

I added this line to my local file and it works, however there is another error:

[...]
root - INFO - BBAVector model will process the images...
root - INFO - loaded weights from /mount_dir/training/model_best.pth, epoch 0
Traceback (most recent call last):
  File "tools/test/bbavector/test_patch.py", line 106, in <module>
    main(args)
  File "tools/test/bbavector/test_patch.py", line 88, in main
    save_patch_results(
  File "/satellitepy/satellitepy/evaluate/bbavector/tools.py", line 65, in save_patch_results
    model_decoder = get_model_decoder(tasks,
TypeError: get_model_decoder() missing 1 required positional argument: 'target_task'

What am I missing here ? Is this ("tools/test/bbavector/test_patch.py") even the correct script to test my model ?

All the best

LNdr28 commented 5 months ago

We've been mostly using tools/test/test_original_images.py recently, so test_patch.py wasn't up to date although it is the correct script in this case. It should be working now. If there are still issues, please reach out again and use tools/test/test_original_images.py with the additional parameters --patch-size 1024 --patch-overlap 0 in the meantime. The functionality is the same if the patch size is equal to the size of the input images, but it may be a bit slower.

Iammuratc commented 5 months ago

I just realized that the evaluation part in README was wrong. I updated it.

bobbender commented 5 months ago

Hey thx for your answers and updates. When I use the tools/test/test_original_images.py with the setting additional parameters: --patch-size 1024 --patch-overlap 0 I get the error:

  File "/opt/project/tools/test/bbavector/test_original_image.py", line 119, in <module>
    main(args)
  File "/opt/project/tools/test/bbavector/test_original_image.py", line 112, in main
    nms_iou_threshold=args.nms_iou_thresh,
AttributeError: 'Namespace' object has no attribute 'nms_iou_thresh'

But as I see it, the bbavector/tools.py --> save_original_image_results() function doesn't need the param: "nms_iou_threshold", so I simply removed this line: nms_iou_threshold=args.nms_iou_thresh, --> line 112 in tools/test/bbavector/test_original_image.py. And it works just fine.