Gabriel commited on
Commit
d76b5dc
1 Parent(s): 5202e66

added image for about

Browse files
app.py CHANGED
@@ -1,7 +1,10 @@
1
  import gradio as gr
2
 
3
  from helper.gradio_config import css, js, theme
4
- from helper.text import TextAbout, TextApp, TextHowTo, TextRoadmap
 
 
 
5
  from tabs.htr_tool import htr_tool_tab
6
  from tabs.stepwise_htr_tool import stepwise_htr_tool_tab
7
 
@@ -97,33 +100,23 @@ print(job.result())
97
  with gr.Tab("About"):
98
  with gr.Tabs():
99
  with gr.Tab("Project"):
 
 
 
 
 
 
 
 
 
 
 
 
100
  with gr.Row():
101
  with gr.Column():
102
- gr.Markdown(TextAbout.intro_and_pipeline_overview_text)
103
- with gr.Row():
104
- with gr.Tabs():
105
- with gr.Tab("I. Binarization"):
106
- gr.Markdown(TextAbout.binarization)
107
- with gr.Tab("II. Region Segmentation"):
108
- gr.Markdown(TextAbout.text_region_segment)
109
- with gr.Tab("III. Line Segmentation"):
110
- gr.Markdown(TextAbout.text_line_segmentation)
111
- with gr.Tab("IV. Transcriber"):
112
- gr.Markdown(TextAbout.text_htr)
113
- with gr.Row():
114
- gr.Markdown(TextAbout.text_data)
115
-
116
  with gr.Column():
117
- gr.Markdown(TextAbout.filler_text_data)
118
  gr.Markdown(TextAbout.text_models)
119
- with gr.Row():
120
- with gr.Tabs():
121
- with gr.Tab("Region Segmentation"):
122
- gr.Markdown(TextAbout.text_models_region)
123
- with gr.Tab("Line Segmentation"):
124
- gr.Markdown(TextAbout.text_line_segmentation)
125
- with gr.Tab("Transcriber"):
126
- gr.Markdown(TextAbout.text_models_htr)
127
 
128
  with gr.Tab("Roadmap"):
129
  with gr.Row():
@@ -131,8 +124,6 @@ print(job.result())
131
  gr.Markdown(TextRoadmap.roadmap)
132
  with gr.Column():
133
  gr.Markdown(TextRoadmap.discussion)
134
- with gr.Row():
135
- gr.Markdown(TextRoadmap.roadmap_image)
136
 
137
  demo.load(None, None, None, _js=js)
138
 
 
1
  import gradio as gr
2
 
3
  from helper.gradio_config import css, js, theme
4
+ from helper.text.text_about import TextAbout
5
+ from helper.text.text_app import TextApp
6
+ from helper.text.text_howto import TextHowTo
7
+ from helper.text.text_roadmap import TextRoadmap
8
  from tabs.htr_tool import htr_tool_tab
9
  from tabs.stepwise_htr_tool import stepwise_htr_tool_tab
10
 
 
100
  with gr.Tab("About"):
101
  with gr.Tabs():
102
  with gr.Tab("Project"):
103
+ with gr.Row():
104
+ gr.Markdown(TextAbout.intro_and_pipeline_overview_text)
105
+ with gr.Row():
106
+ with gr.Tabs():
107
+ with gr.Tab("I. Binarization"):
108
+ gr.Markdown(TextAbout.binarization)
109
+ with gr.Tab("II. Region Segmentation"):
110
+ gr.Markdown(TextAbout.text_region_segment)
111
+ with gr.Tab("III. Line Segmentation"):
112
+ gr.Markdown(TextAbout.text_line_segmentation)
113
+ with gr.Tab("IV. Transcriber"):
114
+ gr.Markdown(TextAbout.text_htr)
115
  with gr.Row():
116
  with gr.Column():
117
+ gr.Markdown(TextAbout.text_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  with gr.Column():
 
119
  gr.Markdown(TextAbout.text_models)
 
 
 
 
 
 
 
 
120
 
121
  with gr.Tab("Roadmap"):
122
  with gr.Row():
 
124
  gr.Markdown(TextRoadmap.roadmap)
125
  with gr.Column():
126
  gr.Markdown(TextRoadmap.discussion)
 
 
127
 
128
  demo.load(None, None, None, _js=js)
129
 
helper/text/__init__.py CHANGED
@@ -1,8 +0,0 @@
1
- from helper.text.text_about import TextAbout
2
- from helper.text.text_app import TextApp
3
- from helper.text.text_howto import TextHowTo
4
- from helper.text.text_riksarkivet import TextRiksarkivet
5
- from helper.text.text_roadmap import TextRoadmap
6
-
7
- if __name__ == "__main__":
8
- pass
 
 
 
 
 
 
 
 
 
helper/text/text_about.py CHANGED
@@ -3,7 +3,9 @@ class TextAbout:
3
  intro_and_pipeline_overview_text = """
4
 
5
  ## Introduction
6
- The Swedish National Archives presents an end-to-end HTR-pipeline consisting of two RTMDet instance segmentation models, trained with MMDetection, one for segmenting text-regions, and one for segmenting text-lines within these regions, and one SATRN HTR-model trained with MMOCR. The aim is for a generic pipline for running-text documents ranging from 1600 to 1900. We will retrain and update the models continually as more data becomes avaialable. Feel free to try out the pipline yourself in our interactive demo (reference).
 
 
7
 
8
  ## The Pipeline in Overview
9
 
@@ -16,24 +18,37 @@ class TextAbout:
16
  The reason for binarizing the images before processing them is that we want the models to generalize as well as possible.
17
  By training on only binarized images and by binarizing images before running them through the pipeline, we take the target domain closer to the training domain, and ruduce negative effects of background variation, background noise etc., on the final results.
18
  The pipeline implements a simple adaptive thresholding algorithm for binarization.
 
 
 
 
19
  """
20
  text_region_segment = """
21
  ### Text-region segmentation
22
  To facilitate the text-line segmentation process, it is advantageous to segment the image into text-regions beforehand. This initial step offers several benefits, including reducing variations in line spacing, eliminating blank areas on the page, establishing a clear reading order, and distinguishing marginalia from the main text.
23
  The segmentation model utilized in this process predicts both bounding boxes and masks. Although the model has the capability to predict both, only the masks are utilized for the segmentation tasks of lines and regions.
24
  An essential post-processing step involves checking for regions that are contained within other regions. During this step, only the containing region is retained, while the contained region is discarded. This ensures that the final segmented text-regions are accurate and devoid of overlapping or redundant areas.
 
 
 
25
  """
26
  text_line_segmentation = """
27
  ### Text-line segmentation
28
 
29
  This is also an RTMDet model that's trained on extracting text-lines from cropped text-regions within an image.
30
  The same post-processing on the instance segmentation masks is done here as in the text-region segmentation step.
 
 
 
31
  """
32
  text_htr = """
33
  ### HTR
34
 
35
- For the text-recognition a SATRN model (reference) was trained with mmocr on approximately one million handwritten text-line images ranging from 1600 to 1900.
36
  It was trained on a wide variety of archival material to make it generalize as well as possible. See below for detailed evaluation results, and also some finetuning experiments.
 
 
 
37
  """
38
 
39
  text_data = """
@@ -42,35 +57,12 @@ class TextAbout:
42
 
43
  """
44
 
45
- filler_text_data = """
46
- ##  
47
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
48
- """
49
-
50
  text_models = """
51
  ## The Models
52
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
53
 
54
  """
55
 
56
- text_models_region = """
57
-
58
- ### Text-Region Segmentation
59
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
60
- """
61
-
62
- text_models_lines = """
63
- ### Text-Line Segmentation
64
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
65
-
66
- """
67
-
68
- text_models_htr = """
69
- ### HTR
70
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
71
-
72
- """
73
-
74
 
75
  if __name__ == "__main__":
76
  pass
 
3
  intro_and_pipeline_overview_text = """
4
 
5
  ## Introduction
6
+ The Swedish National Archives presents an end-to-end HTR-pipeline consisting of two RTMDet instance segmentation models, trained with MMDetection, one for segmenting text-regions, and one for segmenting text-lines within these regions, and one SATRN HTR-model trained with MMOCR.
7
+ The aim is for a generic pipline for running-text documents ranging from 1600 to 1900.
8
+ We will retrain and update the models continually as more data becomes avaialable.
9
 
10
  ## The Pipeline in Overview
11
 
 
18
  The reason for binarizing the images before processing them is that we want the models to generalize as well as possible.
19
  By training on only binarized images and by binarizing images before running them through the pipeline, we take the target domain closer to the training domain, and ruduce negative effects of background variation, background noise etc., on the final results.
20
  The pipeline implements a simple adaptive thresholding algorithm for binarization.
21
+ <figure>
22
+ <img src="https://raw.githubusercontent.com/Borg93/htr_gradio_file_placeholder/main/roadmap_image_2.png" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
23
+ </figure>
24
+
25
  """
26
  text_region_segment = """
27
  ### Text-region segmentation
28
  To facilitate the text-line segmentation process, it is advantageous to segment the image into text-regions beforehand. This initial step offers several benefits, including reducing variations in line spacing, eliminating blank areas on the page, establishing a clear reading order, and distinguishing marginalia from the main text.
29
  The segmentation model utilized in this process predicts both bounding boxes and masks. Although the model has the capability to predict both, only the masks are utilized for the segmentation tasks of lines and regions.
30
  An essential post-processing step involves checking for regions that are contained within other regions. During this step, only the containing region is retained, while the contained region is discarded. This ensures that the final segmented text-regions are accurate and devoid of overlapping or redundant areas.
31
+ <figure>
32
+ <img src="https://raw.githubusercontent.com/Borg93/htr_gradio_file_placeholder/main/roadmap_image_2.png" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
33
+ </figure>
34
  """
35
  text_line_segmentation = """
36
  ### Text-line segmentation
37
 
38
  This is also an RTMDet model that's trained on extracting text-lines from cropped text-regions within an image.
39
  The same post-processing on the instance segmentation masks is done here as in the text-region segmentation step.
40
+ <figure>
41
+ <img src="https://raw.githubusercontent.com/Borg93/htr_gradio_file_placeholder/main/roadmap_image_2.png" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
42
+ </figure>
43
  """
44
  text_htr = """
45
  ### HTR
46
 
47
+ For the text-recognition a SATRN model was trained with mmocr on approximately one million handwritten text-line images ranging from 1600 to 1900.
48
  It was trained on a wide variety of archival material to make it generalize as well as possible. See below for detailed evaluation results, and also some finetuning experiments.
49
+ <figure>
50
+ <img src="https://raw.githubusercontent.com/Borg93/htr_gradio_file_placeholder/main/roadmap_image_2.png" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
51
+ </figure>
52
  """
53
 
54
  text_data = """
 
57
 
58
  """
59
 
 
 
 
 
 
60
  text_models = """
61
  ## The Models
62
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
63
 
64
  """
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  if __name__ == "__main__":
68
  pass
helper/text/text_riksarkivet.py DELETED
@@ -1,10 +0,0 @@
1
- class TextRiksarkivet:
2
- riksarkivet = """
3
-
4
-
5
-
6
- """
7
-
8
-
9
- if __name__ == "__main__":
10
- pass