Repository: mindee/doctr

Issue:
Unable to run the demo using the main branch
### Bug description

tried using latest master with streamlit demo as described in intro page.

provided a picture with a UK Car in it, to see if it reads the plate text.  It returned with the following failure.

Strange, i used this 3 months ago, and was totally fine, and the recognition was really good, some how now its simply not working as good, infact alot worse.  I have used the api way, and that seems to work ok, but still alot worse than what it was before.
Picture was: 

```
KeyError: 'out_map'
Traceback:
File "D:\Python39\lib\site-packages\streamlit\script_runner.py", line 354, in _run_script
    exec(code, module.__dict__)
File "D:\gitsrc\opensource\doctr\demo\app.py", line 109, in <module>
    main()
File "D:\gitsrc\opensource\doctr\demo\app.py", line 83, in main
    seg_map = out["out_map"]
```
### Code snippet to reproduce the bug

for Web app:
```shell
streamlit run demo/app.py
```
For API:
```shell
uvicorn --reload --workers 1 --host 0.0.0.0 --port=8002 --app-dir api/ app.main:app
```
with client code as:
```python
import requests
import io
import json

with open('D:/ImagesTest/NOREG_4127_20190324_2113499334_cpc2jh1m.jpg', 'rb') as f:
  data = f.read()
response = requests.post("http://localhost:8002/ocr", files={'file': data}).json()

with open('dataapi.json', 'w', encoding='utf-8') as f:
    json.dump(response, f, ensure_ascii=False, indent=4)
```
### Error traceback
```
KeyError: 'out_map'
Traceback:
File "D:\Python39\lib\site-packages\streamlit\script_runner.py", line 354, in _run_script
    exec(code, module.__dict__)
File "D:\gitsrc\opensource\doctr\demo\app.py", line 109, in <module>
    main()
File "D:\gitsrc\opensource\doctr\demo\app.py", line 83, in main
    seg_map = out["out_map"]
```
### Environment

running on Windows 10 Pro
latest python

the collect_env.py wont work properly under wsl2.

```
Traceback (most recent call last):
  File "collect_env.py", line 24, in <module>
    import doctr
  File "/mnt/d/gitsrc/opensource/doctr/doctr/__init__.py", line 1, in <module>
    from . import datasets, io, models, transforms, utils
  File "/mnt/d/gitsrc/opensource/doctr/doctr/datasets/__init__.py", line 1, in <module>
    from doctr.file_utils import is_tf_available
  File "/mnt/d/gitsrc/opensource/doctr/doctr/file_utils.py", line 33
    logging.info(f"PyTorch version {_torch_version} available.")
                                                              ^
SyntaxError: invalid syntax
```


Discussion:
Hello @rclarke2050 :wave: 

You mentioned a picture in the issue description, but it seems to pasted a code snippet instead of the intended picture :sweat_smile: Would you mind sharing it so that we can debug this?

Also, you mentioned that the environment collection script isn't working with WSL2. Are you positive that you're running Python 3? Because your failure mentions a syntax error on a perfectly fine Python3 syntax (at least to the best of my knowledge) :thinking: 

Best,
Facing similar issue while executing via the demo app. The same image works fine with the api and docker set-up. Below is the error along with the environment details.
Tried disabling the GPU and still got the same error message

*************************************************************
$ streamlit run demo/app.py

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://172.19.36.252:8501

2022-01-18 23:50:47.130 PyTorch version 1.10.1+cu113 available.
2022-01-18 23:50:47.140 TensorFlow version 2.5.0rc3 available.
2022-01-18 23:51:04.898 Using downloaded & verified file: /home/idxuser02/.cache/doctr/models/db_resnet50-adcafc63.zip
2022-01-18 23:51:05.543 Layer lstm will use cuDNN kernels when running on GPU.
2022-01-18 23:51:05.545 Layer lstm will use cuDNN kernels when running on GPU.
2022-01-18 23:51:05.547 Layer lstm will use cuDNN kernels when running on GPU.
2022-01-18 23:51:05.548 Layer lstm_1 will use cuDNN kernels when running on GPU.
2022-01-18 23:51:05.550 Layer lstm_1 will use cuDNN kernels when running on GPU.
2022-01-18 23:51:05.552 Layer lstm_1 will use cuDNN kernels when running on GPU.
Downloading https://github.com/mindee/doctr/releases/download/v0.3.0/crnn_vgg16_bn-76b7f2c6.zip to /home/idxuser02/.cache/doctr/models/crnn_vgg16_bn-76b7f2c6.zip
58759168it [00:03, 17994109.05it/s]                                                                      
2022-01-18 23:51:15.522 Traceback (most recent call last):
  File "/home/idxuser02/miniconda3/envs/doctr-pytorch/lib/python3.8/site-packages/streamlit/script_runner.py", line 379, in _run_script
    exec(code, module.__dict__)
  File "/home/idxuser02/Documents/demo/doctr/demo/app.py", line 109, in <module>
    main()
  File "/home/idxuser02/Documents/demo/doctr/demo/app.py", line 83, in main
    seg_map = out["out_map"]
KeyError: 'out_map'
*************************************************************************************************

Collecting environment information...

DocTR version: 0.5.1a0
TensorFlow version: 2.5.0-rc3
PyTorch version: 1.10.1+cu113 (torchvision 0.11.2+cu113)
OpenCV version: 4.5.4
OS: Ubuntu 20.04.2 LTS
Python version: 3.8.0
Is CUDA available (TensorFlow): Yes
Is CUDA available (PyTorch): Yes
CUDA runtime version: 11.2.152
GPU models and configuration: GPU 0: GeForce RTX 3090
Nvidia driver version: 460.91.03
cuDNN version: Probably one of the following:
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.1

******************************************************************************************


Resolving patch:
diff --git a/demo/app.py b/demo/app.py
--- a/demo/app.py
+++ b/demo/app.py
@@ -79,7 +79,7 @@ def main():
 
                 # Forward the image to the model
                 processed_batches = predictor.det_predictor.pre_processor([doc[page_idx]])
-                out = predictor.det_predictor.model(processed_batches[0], return_preds=True)
+                out = predictor.det_predictor.model(processed_batches[0], return_model_output=True)
                 seg_map = out["out_map"]
                 seg_map = tf.squeeze(seg_map[0, ...], axis=[2])
                 seg_map = cv2.resize(seg_map.numpy(), (doc[page_idx].shape[1], doc[page_idx].shape[0]),


Test patch: