Issues in tile inference script
Hi there, thank you for providing this code and the associated checkpoints!
While trying to run the inference script on the CoNSeP test set (using the following command: python run_infer.py --nr_types=5 --model_path=./chkpt/hovernet_original_consep_type_tf2pytorch.tar --model_mode=original tile --input_dir=./CoNSeP/Test/Images --output_dir=./test_output), I ran into (and fixed) two issues.
- In
run_infer.py:125, whenmethod_args['type_info_path']is set, it is set as follows:
'type_info_path' : None if args['type_info_path'] == '' else args['type_info_path'],
This checks whether that arg is an empty string and replaces it with None if that is the case. However, when the default args are initialized, type_info_path is set to the string '' (in other words, it is the string "''"). This leads to an error when trying to access the path '', because the check did not pass, so type_info_path is not None.
One possible fix is changing the line to
'type_info_path' : None if args['type_info_path'] == "''" else args['type_info_path'],
- In
viz_utils.py:119, when plotting instances usingcv2.drawContours, the call is
cv2.drawContours(overlay, [inst_contour], -1, inst_colour, line_thickness)
This leads to the error TypeError: Scalar value for argument 'color' is not numeric.. As best I can tell, this is because inst_colour is a tuple of numpy.uint8, which cv2 does not accept. It is set to that here.
The fix is changing the call to
cv2.drawContours(overlay, [inst_contour], -1, tuple(int(el) for el in inst_colour), line_thickness)
Let me know if you'd like me to submit a PR with these fixes.
Thank you again for making this available.
Sounds good to me, opencv and drawcontour is a pain because their API will break things and spit out very uninformative errors. If anyone else have problem I will just fix later.
@proever please can you confirm the version of opencv that you are using. Did you use the version as specified in requirements.txt ?
@proever please can you confirm the version of opencv that you are using. Did you use the version as specified in
requirements.txt?
apologies, I must have missed this. It's version 4.3.0, which seems to be aligned with what's in requirements.txt (except the final .36 I suppose.