We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `demo/app.py`
Content:
```
1 # Copyright (C) 2021-2022, Mindee.
2 
3 # This program is licensed under the Apache License version 2.
4 # See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
5 
6 import os
7 
8 import matplotlib.pyplot as plt
9 import streamlit as st
10 
11 os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
12 
13 import cv2
14 import tensorflow as tf
15 
16 gpu_devices = tf.config.experimental.list_physical_devices('GPU')
17 if any(gpu_devices):
18     tf.config.experimental.set_memory_growth(gpu_devices[0], True)
19 
20 from doctr.io import DocumentFile
21 from doctr.models import ocr_predictor
22 from doctr.utils.visualization import visualize_page
23 
24 DET_ARCHS = ["db_resnet50", "db_mobilenet_v3_large"]
25 RECO_ARCHS = ["crnn_vgg16_bn", "crnn_mobilenet_v3_small", "master", "sar_resnet31"]
26 
27 
28 def main():
29 
30     # Wide mode
31     st.set_page_config(layout="wide")
32 
33     # Designing the interface
34     st.title("docTR: Document Text Recognition")
35     # For newline
36     st.write('\n')
37     # Instructions
38     st.markdown("*Hint: click on the top-right corner of an image to enlarge it!*")
39     # Set the columns
40     cols = st.columns((1, 1, 1, 1))
41     cols[0].subheader("Input page")
42     cols[1].subheader("Segmentation heatmap")
43     cols[2].subheader("OCR output")
44     cols[3].subheader("Page reconstitution")
45 
46     # Sidebar
47     # File selection
48     st.sidebar.title("Document selection")
49     # Disabling warning
50     st.set_option('deprecation.showfileUploaderEncoding', False)
51     # Choose your own image
52     uploaded_file = st.sidebar.file_uploader("Upload files", type=['pdf', 'png', 'jpeg', 'jpg'])
53     if uploaded_file is not None:
54         if uploaded_file.name.endswith('.pdf'):
55             doc = DocumentFile.from_pdf(uploaded_file.read()).as_images()
56         else:
57             doc = DocumentFile.from_images(uploaded_file.read())
58         page_idx = st.sidebar.selectbox("Page selection", [idx + 1 for idx in range(len(doc))]) - 1
59         cols[0].image(doc[page_idx])
60 
61     # Model selection
62     st.sidebar.title("Model selection")
63     det_arch = st.sidebar.selectbox("Text detection model", DET_ARCHS)
64     reco_arch = st.sidebar.selectbox("Text recognition model", RECO_ARCHS)
65 
66     # For newline
67     st.sidebar.write('\n')
68 
69     if st.sidebar.button("Analyze page"):
70 
71         if uploaded_file is None:
72             st.sidebar.write("Please upload a document")
73 
74         else:
75             with st.spinner('Loading model...'):
76                 predictor = ocr_predictor(det_arch, reco_arch, pretrained=True)
77 
78             with st.spinner('Analyzing...'):
79 
80                 # Forward the image to the model
81                 processed_batches = predictor.det_predictor.pre_processor([doc[page_idx]])
82                 out = predictor.det_predictor.model(processed_batches[0], return_preds=True)
83                 seg_map = out["out_map"]
84                 seg_map = tf.squeeze(seg_map[0, ...], axis=[2])
85                 seg_map = cv2.resize(seg_map.numpy(), (doc[page_idx].shape[1], doc[page_idx].shape[0]),
86                                      interpolation=cv2.INTER_LINEAR)
87                 # Plot the raw heatmap
88                 fig, ax = plt.subplots()
89                 ax.imshow(seg_map)
90                 ax.axis('off')
91                 cols[1].pyplot(fig)
92 
93                 # Plot OCR output
94                 out = predictor([doc[page_idx]])
95                 fig = visualize_page(out.pages[0].export(), doc[page_idx], interactive=False)
96                 cols[2].pyplot(fig)
97 
98                 # Page reconsitution under input page
99                 page_export = out.pages[0].export()
100                 img = out.pages[0].synthesize()
101                 cols[3].image(img, clamp=True)
102 
103                 # Display JSON
104                 st.markdown("\nHere are your analysis results in JSON format:")
105                 st.json(page_export)
106 
107 
108 if __name__ == '__main__':
109     main()
110
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/demo/app.py b/demo/app.py
--- a/demo/app.py
+++ b/demo/app.py
@@ -79,7 +79,7 @@
 
                 # 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]),

{"golden_diff": "diff --git a/demo/app.py b/demo/app.py\n--- a/demo/app.py\n+++ b/demo/app.py\n@@ -79,7 +79,7 @@\n \n                 # Forward the image to the model\n                 processed_batches = predictor.det_predictor.pre_processor([doc[page_idx]])\n-                out = predictor.det_predictor.model(processed_batches[0], return_preds=True)\n+                out = predictor.det_predictor.model(processed_batches[0], return_model_output=True)\n                 seg_map = out[\"out_map\"]\n                 seg_map = tf.squeeze(seg_map[0, ...], axis=[2])\n                 seg_map = cv2.resize(seg_map.numpy(), (doc[page_idx].shape[1], doc[page_idx].shape[0]),\n", "issue": "Unable to run the demo using the main branch\n### Bug description\r\n\r\ntried using latest master with streamlit demo as described in intro page.\r\n\r\nprovided a picture with a UK Car in it, to see if it reads the plate text.  It returned with the following failure.\r\n\r\nStrange, 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.\r\nPicture was: \r\n\r\n```\r\nKeyError: 'out_map'\r\nTraceback:\r\nFile \"D:\\Python39\\lib\\site-packages\\streamlit\\script_runner.py\", line 354, in _run_script\r\n    exec(code, module.__dict__)\r\nFile \"D:\\gitsrc\\opensource\\doctr\\demo\\app.py\", line 109, in <module>\r\n    main()\r\nFile \"D:\\gitsrc\\opensource\\doctr\\demo\\app.py\", line 83, in main\r\n    seg_map = out[\"out_map\"]\r\n```\r\n### Code snippet to reproduce the bug\r\n\r\nfor Web app:\r\n```shell\r\nstreamlit run demo/app.py\r\n```\r\nFor API:\r\n```shell\r\nuvicorn --reload --workers 1 --host 0.0.0.0 --port=8002 --app-dir api/ app.main:app\r\n```\r\nwith client code as:\r\n```python\r\nimport requests\r\nimport io\r\nimport json\r\n\r\nwith open('D:/ImagesTest/NOREG_4127_20190324_2113499334_cpc2jh1m.jpg', 'rb') as f:\r\n  data = f.read()\r\nresponse = requests.post(\"http://localhost:8002/ocr\", files={'file': data}).json()\r\n\r\nwith open('dataapi.json', 'w', encoding='utf-8') as f:\r\n    json.dump(response, f, ensure_ascii=False, indent=4)\r\n```\r\n### Error traceback\r\n```\r\nKeyError: 'out_map'\r\nTraceback:\r\nFile \"D:\\Python39\\lib\\site-packages\\streamlit\\script_runner.py\", line 354, in _run_script\r\n    exec(code, module.__dict__)\r\nFile \"D:\\gitsrc\\opensource\\doctr\\demo\\app.py\", line 109, in <module>\r\n    main()\r\nFile \"D:\\gitsrc\\opensource\\doctr\\demo\\app.py\", line 83, in main\r\n    seg_map = out[\"out_map\"]\r\n```\r\n### Environment\r\n\r\nrunning on Windows 10 Pro\r\nlatest python\r\n\r\nthe collect_env.py wont work properly under wsl2.\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"collect_env.py\", line 24, in <module>\r\n    import doctr\r\n  File \"/mnt/d/gitsrc/opensource/doctr/doctr/__init__.py\", line 1, in <module>\r\n    from . import datasets, io, models, transforms, utils\r\n  File \"/mnt/d/gitsrc/opensource/doctr/doctr/datasets/__init__.py\", line 1, in <module>\r\n    from doctr.file_utils import is_tf_available\r\n  File \"/mnt/d/gitsrc/opensource/doctr/doctr/file_utils.py\", line 33\r\n    logging.info(f\"PyTorch version {_torch_version} available.\")\r\n                                                              ^\r\nSyntaxError: invalid syntax\r\n```\n", "before_files": [{"content": "# Copyright (C) 2021-2022, Mindee.\n\n# This program is licensed under the Apache License version 2.\n# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport streamlit as st\n\nos.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"2\"\n\nimport cv2\nimport tensorflow as tf\n\ngpu_devices = tf.config.experimental.list_physical_devices('GPU')\nif any(gpu_devices):\n    tf.config.experimental.set_memory_growth(gpu_devices[0], True)\n\nfrom doctr.io import DocumentFile\nfrom doctr.models import ocr_predictor\nfrom doctr.utils.visualization import visualize_page\n\nDET_ARCHS = [\"db_resnet50\", \"db_mobilenet_v3_large\"]\nRECO_ARCHS = [\"crnn_vgg16_bn\", \"crnn_mobilenet_v3_small\", \"master\", \"sar_resnet31\"]\n\n\ndef main():\n\n    # Wide mode\n    st.set_page_config(layout=\"wide\")\n\n    # Designing the interface\n    st.title(\"docTR: Document Text Recognition\")\n    # For newline\n    st.write('\\n')\n    # Instructions\n    st.markdown(\"*Hint: click on the top-right corner of an image to enlarge it!*\")\n    # Set the columns\n    cols = st.columns((1, 1, 1, 1))\n    cols[0].subheader(\"Input page\")\n    cols[1].subheader(\"Segmentation heatmap\")\n    cols[2].subheader(\"OCR output\")\n    cols[3].subheader(\"Page reconstitution\")\n\n    # Sidebar\n    # File selection\n    st.sidebar.title(\"Document selection\")\n    # Disabling warning\n    st.set_option('deprecation.showfileUploaderEncoding', False)\n    # Choose your own image\n    uploaded_file = st.sidebar.file_uploader(\"Upload files\", type=['pdf', 'png', 'jpeg', 'jpg'])\n    if uploaded_file is not None:\n        if uploaded_file.name.endswith('.pdf'):\n            doc = DocumentFile.from_pdf(uploaded_file.read()).as_images()\n        else:\n            doc = DocumentFile.from_images(uploaded_file.read())\n        page_idx = st.sidebar.selectbox(\"Page selection\", [idx + 1 for idx in range(len(doc))]) - 1\n        cols[0].image(doc[page_idx])\n\n    # Model selection\n    st.sidebar.title(\"Model selection\")\n    det_arch = st.sidebar.selectbox(\"Text detection model\", DET_ARCHS)\n    reco_arch = st.sidebar.selectbox(\"Text recognition model\", RECO_ARCHS)\n\n    # For newline\n    st.sidebar.write('\\n')\n\n    if st.sidebar.button(\"Analyze page\"):\n\n        if uploaded_file is None:\n            st.sidebar.write(\"Please upload a document\")\n\n        else:\n            with st.spinner('Loading model...'):\n                predictor = ocr_predictor(det_arch, reco_arch, pretrained=True)\n\n            with st.spinner('Analyzing...'):\n\n                # Forward the image to the model\n                processed_batches = predictor.det_predictor.pre_processor([doc[page_idx]])\n                out = predictor.det_predictor.model(processed_batches[0], return_preds=True)\n                seg_map = out[\"out_map\"]\n                seg_map = tf.squeeze(seg_map[0, ...], axis=[2])\n                seg_map = cv2.resize(seg_map.numpy(), (doc[page_idx].shape[1], doc[page_idx].shape[0]),\n                                     interpolation=cv2.INTER_LINEAR)\n                # Plot the raw heatmap\n                fig, ax = plt.subplots()\n                ax.imshow(seg_map)\n                ax.axis('off')\n                cols[1].pyplot(fig)\n\n                # Plot OCR output\n                out = predictor([doc[page_idx]])\n                fig = visualize_page(out.pages[0].export(), doc[page_idx], interactive=False)\n                cols[2].pyplot(fig)\n\n                # Page reconsitution under input page\n                page_export = out.pages[0].export()\n                img = out.pages[0].synthesize()\n                cols[3].image(img, clamp=True)\n\n                # Display JSON\n                st.markdown(\"\\nHere are your analysis results in JSON format:\")\n                st.json(page_export)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "demo/app.py"}], "after_files": [{"content": "# Copyright (C) 2021-2022, Mindee.\n\n# This program is licensed under the Apache License version 2.\n# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport streamlit as st\n\nos.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"2\"\n\nimport cv2\nimport tensorflow as tf\n\ngpu_devices = tf.config.experimental.list_physical_devices('GPU')\nif any(gpu_devices):\n    tf.config.experimental.set_memory_growth(gpu_devices[0], True)\n\nfrom doctr.io import DocumentFile\nfrom doctr.models import ocr_predictor\nfrom doctr.utils.visualization import visualize_page\n\nDET_ARCHS = [\"db_resnet50\", \"db_mobilenet_v3_large\"]\nRECO_ARCHS = [\"crnn_vgg16_bn\", \"crnn_mobilenet_v3_small\", \"master\", \"sar_resnet31\"]\n\n\ndef main():\n\n    # Wide mode\n    st.set_page_config(layout=\"wide\")\n\n    # Designing the interface\n    st.title(\"docTR: Document Text Recognition\")\n    # For newline\n    st.write('\\n')\n    # Instructions\n    st.markdown(\"*Hint: click on the top-right corner of an image to enlarge it!*\")\n    # Set the columns\n    cols = st.columns((1, 1, 1, 1))\n    cols[0].subheader(\"Input page\")\n    cols[1].subheader(\"Segmentation heatmap\")\n    cols[2].subheader(\"OCR output\")\n    cols[3].subheader(\"Page reconstitution\")\n\n    # Sidebar\n    # File selection\n    st.sidebar.title(\"Document selection\")\n    # Disabling warning\n    st.set_option('deprecation.showfileUploaderEncoding', False)\n    # Choose your own image\n    uploaded_file = st.sidebar.file_uploader(\"Upload files\", type=['pdf', 'png', 'jpeg', 'jpg'])\n    if uploaded_file is not None:\n        if uploaded_file.name.endswith('.pdf'):\n            doc = DocumentFile.from_pdf(uploaded_file.read()).as_images()\n        else:\n            doc = DocumentFile.from_images(uploaded_file.read())\n        page_idx = st.sidebar.selectbox(\"Page selection\", [idx + 1 for idx in range(len(doc))]) - 1\n        cols[0].image(doc[page_idx])\n\n    # Model selection\n    st.sidebar.title(\"Model selection\")\n    det_arch = st.sidebar.selectbox(\"Text detection model\", DET_ARCHS)\n    reco_arch = st.sidebar.selectbox(\"Text recognition model\", RECO_ARCHS)\n\n    # For newline\n    st.sidebar.write('\\n')\n\n    if st.sidebar.button(\"Analyze page\"):\n\n        if uploaded_file is None:\n            st.sidebar.write(\"Please upload a document\")\n\n        else:\n            with st.spinner('Loading model...'):\n                predictor = ocr_predictor(det_arch, reco_arch, pretrained=True)\n\n            with st.spinner('Analyzing...'):\n\n                # Forward the image to the model\n                processed_batches = predictor.det_predictor.pre_processor([doc[page_idx]])\n                out = predictor.det_predictor.model(processed_batches[0], return_model_output=True)\n                seg_map = out[\"out_map\"]\n                seg_map = tf.squeeze(seg_map[0, ...], axis=[2])\n                seg_map = cv2.resize(seg_map.numpy(), (doc[page_idx].shape[1], doc[page_idx].shape[0]),\n                                     interpolation=cv2.INTER_LINEAR)\n                # Plot the raw heatmap\n                fig, ax = plt.subplots()\n                ax.imshow(seg_map)\n                ax.axis('off')\n                cols[1].pyplot(fig)\n\n                # Plot OCR output\n                out = predictor([doc[page_idx]])\n                fig = visualize_page(out.pages[0].export(), doc[page_idx], interactive=False)\n                cols[2].pyplot(fig)\n\n                # Page reconsitution under input page\n                page_export = out.pages[0].export()\n                img = out.pages[0].synthesize()\n                cols[3].image(img, clamp=True)\n\n                # Display JSON\n                st.markdown(\"\\nHere are your analysis results in JSON format:\")\n                st.json(page_export)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "demo/app.py"}]}