Commit 3242b1a
authored
🐛 Fix
This pull request fixes issues with the SCCNN model. Solving issue #969 .
- [x] Fix model forward function
- [x] Fix model preproc typing
- [x] Fix tests
- [x] Fix model config
Firstly, the unit test is fixed by adding `model.preproc(patch)` step before calling `infer_batch()`, pre-processing function is supposed to be applied on the input patch before the model's forward pass in our engines.
In the unit test, `assert` is changed using numpy's assert function to compare two arrays. Previously what happened was the output could be an empty numpy array of shape `(0,2)`, the assert would still return `True`, which was wrong and unsafe. Example:
```python
postproc_output = np.array([]).reshape(0, 2)
print(postproc_output) # []
print(postproc_output.shape) # (0, 2)
cmp = (postproc_output == [[8, 7]])
print(cmp) # [] with shape (0, 2)
print(np.all(cmp)) # True (!!)
```
I removed `preproc` from SCCNN's `forward()` function. It should not be used here.
Finally, I updated the input resolution for sccnn models, as from the unit test the resolution seems to be 0.25 mpp.
Regarding issue #969 : Previously the test passes, but as `preproc` was applied in the model's `forward` function. When I tried to run the model inside the `SementicSegmentor` engine, `preproc` was essentially ran twice, once from the `dataloader`, and once again in the `sccnn.forward()` function, which meant the input was divided by 255 twice, therefore the model only outputs zeros as the values were too small.sccnn Model (#970)1 parent 1614a1f commit 3242b1a
File tree
3 files changed
+12
-11
lines changed- tests/models
- tiatoolbox
- data
- models/architecture
3 files changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
866 | | - | |
| 866 | + | |
867 | 867 | | |
868 | | - | |
| 868 | + | |
869 | 869 | | |
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
873 | | - | |
| 873 | + | |
874 | 874 | | |
875 | 875 | | |
876 | 876 | | |
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
| 889 | + | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
896 | | - | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | 312 | | |
314 | 313 | | |
315 | 314 | | |
| |||
0 commit comments