Gabriel commited on
Commit
451f882
1 Parent(s): 90192b2

restructuring the text of the app

Browse files
app.py CHANGED
@@ -7,7 +7,6 @@ from helper.gradio_config import css, theme
7
  from helper.text.text_app import TextApp
8
  from helper.utils import TrafficDataHandler
9
  from tabs.about_tab import about_tab
10
- from tabs.help_tab import help_tab
11
  from tabs.htr_tool import htr_tool_tab
12
  from tabs.stepwise_htr_tool import stepwise_htr_tool_tab
13
 
@@ -17,7 +16,7 @@ with gr.Blocks(title="Riksarkivet", theme=theme, css=css) as demo:
17
  with gr.Row():
18
  with gr.Column(scale=1):
19
  text_ip_output = gr.Markdown(TextApp.demo_version)
20
- with gr.Column(scale=1):
21
  gr.Markdown(TextApp.title_markdown)
22
  with gr.Column(scale=1):
23
  gr.Markdown(TextApp.title_markdown_img)
@@ -29,10 +28,7 @@ with gr.Blocks(title="Riksarkivet", theme=theme, css=css) as demo:
29
  with gr.Tab("Stepwise"):
30
  stepwise_htr_tool_tab.render()
31
 
32
- with gr.Tab("Help"):
33
- help_tab.render()
34
-
35
- with gr.Tab("About"):
36
  about_tab.render()
37
 
38
  SECRET_KEY = os.environ.get("AM_I_IN_A_DOCKER_CONTAINER", False)
 
7
  from helper.text.text_app import TextApp
8
  from helper.utils import TrafficDataHandler
9
  from tabs.about_tab import about_tab
 
10
  from tabs.htr_tool import htr_tool_tab
11
  from tabs.stepwise_htr_tool import stepwise_htr_tool_tab
12
 
 
16
  with gr.Row():
17
  with gr.Column(scale=1):
18
  text_ip_output = gr.Markdown(TextApp.demo_version)
19
+ with gr.Column(scale=2):
20
  gr.Markdown(TextApp.title_markdown)
21
  with gr.Column(scale=1):
22
  gr.Markdown(TextApp.title_markdown_img)
 
28
  with gr.Tab("Stepwise"):
29
  stepwise_htr_tool_tab.render()
30
 
31
+ with gr.Tab("Documentation"):
 
 
 
32
  about_tab.render()
33
 
34
  SECRET_KEY = os.environ.get("AM_I_IN_A_DOCKER_CONTAINER", False)
helper/gradio_config.py CHANGED
@@ -24,7 +24,8 @@ class GradioConfig:
24
 
25
  #download_file > div.empty.svelte-lk9eg8.large.unpadded_box {min-height: 100px;}
26
  #gallery_lines > div.preview.svelte-1b19cri > div.thumbnails.scroll-hide.svelte-1b19cri {display: none;}
27
-
 
28
  """
29
 
30
  def generate_tooltip_css(self):
 
24
 
25
  #download_file > div.empty.svelte-lk9eg8.large.unpadded_box {min-height: 100px;}
26
  #gallery_lines > div.preview.svelte-1b19cri > div.thumbnails.scroll-hide.svelte-1b19cri {display: none;}
27
+
28
+ .tr-head.svelte-13hsdno>.svelte-13hsdno+.svelte-13hsdno {display: none;}
29
  """
30
 
31
  def generate_tooltip_css(self):
helper/text/about/changelog_roadmap/current_changelog.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Changelog
2
+
3
+ ### [0.0.1] - 2023-10-19
4
+
5
+ #### Added
6
+
7
+ - Stepwise feature > Explore results > New Text diff and CER components
8
+
9
+ #### Fixed
10
+
11
+ #### Changed
12
+
13
+ - Layout in both Fast track and Stepwise to improve the UX
14
+
15
+ #### Removed
helper/text/about/changelog_roadmap/old_changelog.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Changelog
2
+
3
+ ### [0.0.1] - 2023-10-19
4
+
5
+ #### Added
6
+
7
+ - Stepwise feature > Explore results > New Text diff and CER components
8
+
9
+ #### Fixed
10
+
11
+ #### Changed
12
+
13
+ - Layout in both Fast track and Stepwise to improve the UX
14
+
15
+ #### Removed
helper/text/about/changelog_roadmap/roadmap.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Roadmap
2
+
3
+ #### ☑ Release Model on HuggingFace
4
+
5
+ - Continually retrain and update both segmentation and text-recognition models as more training data becomes available.
6
+
7
+ #### ☐ Release Training and Eval data on HuggingFace
8
+
9
+ #### ☐ Specialized TrOCR Model
10
+
11
+ - Train a TrOCR model specialized on Swedish historical handwritten text.
12
+ - Initialize with a historical BERT-model trained at the Swedish National Archives.
13
+
14
+ #### ☐ Open-source and package HTR-pipeline for mass HTR
15
+
16
+ - Develop an easy-to-implement pipeline like the demo.
17
+ - Ensure high modularity:
18
+ - Different segmentation strategies.
19
+ - Integration of models from various frameworks.
20
+ - Effective evaluation methods for entire pipelines and their comparisons.
21
+ - Broad use-cases: Not just running text, but all types of handwritten archives.
22
+
23
+ #### ☐ Inference Endpoints
24
+
25
+ - Serve model through inference APIs / Rest APIs with dedicated hardware.
helper/text/{text_roadmap.py → about/contributions/contributions.md} RENAMED
@@ -1,60 +1,3 @@
1
- class TextRoadmap:
2
- roadmap = """
3
- ## Roadmap
4
-
5
- #### ☑ Release Model on HuggingFace
6
- - Continually retrain and update both segmentation and text-recognition models as more training data becomes available.
7
-
8
- #### ☐ Release Training and Eval data on HuggingFace
9
-
10
- #### ☐ Specialized TrOCR Model
11
- - Train a TrOCR model specialized on Swedish historical handwritten text.
12
- - Initialize with a historical BERT-model trained at the Swedish National Archives.
13
-
14
- #### ☐ Open-source and package HTR-pipeline for mass HTR
15
- - Develop an easy-to-implement pipeline like the demo.
16
- - Ensure high modularity:
17
- - Different segmentation strategies.
18
- - Integration of models from various frameworks.
19
- - Effective evaluation methods for entire pipelines and their comparisons.
20
- - Broad use-cases: Not just running text, but all types of handwritten archives.
21
-
22
- #### ☐ Inference Endpoints
23
- - Serve model through inference APIs / Rest APIs with dedicated hardware.
24
-
25
- """
26
-
27
- changelog = """
28
-
29
- ## Changelog
30
-
31
- ### [0.0.1] - 2023-10-19
32
-
33
- #### Added
34
-
35
- - Stepwise feature > Explore results > New Text diff and CER components
36
-
37
- #### Fixed
38
-
39
- - -
40
-
41
- #### Changed
42
-
43
- - Layout in both Fast track and Stepwise to improve the UX
44
-
45
- ### Removed
46
-
47
- - -
48
-
49
-
50
- """
51
-
52
- roadmap_image = """
53
- <figure>
54
- <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;" >
55
- </figure> """
56
-
57
- text_contribution = """
58
  ## Project Contributions
59
 
60
  We extend our deepest gratitude to the individuals and organizations who have made this project possible through their invaluable contributions, especially in providing datasets for training the models. Their generosity and collaboration have significantly propelled the project forward.
@@ -82,6 +25,3 @@ For further details on contributions or if you are interested in contributing, p
82
  Thank you!
83
 
84
  // Riksarkivet
85
-
86
-
87
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ## Project Contributions
2
 
3
  We extend our deepest gratitude to the individuals and organizations who have made this project possible through their invaluable contributions, especially in providing datasets for training the models. Their generosity and collaboration have significantly propelled the project forward.
 
25
  Thank you!
26
 
27
  // Riksarkivet
 
 
 
helper/text/about/htrflow.md DELETED
File without changes
helper/text/about/htrflow/htrflow_col1.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Introduction
2
+
3
+ The Swedish National Archives introduces a demonstrational end-to-end HTR (Handwritten Text Recognition) pipeline. This pipeline comprises two instance segmentation models: one designated for segmenting text-regions and another for isolating text-lines within these regions, coupled with an HTR model for image-to-text transcription. The objective of this project is to establish a generic pipeline capable of processing running-text documents spanning from 1600 to 1900.
4
+
5
+ ## Usage
6
+
7
+ It's crucial to emphasize that this application serves primarily for demonstration purposes, aimed at showcasing the various models employed in the current workflow for processing documents with running-text. <br>
8
+
9
+ For an insight into the upcoming features we are working on:
10
+
11
+ - Navigate to the > **About** > **Changelog & Roadmap**.
helper/text/about/htrflow/htrflow_col2.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Source Code
2
+
3
+ Please fork and leave a star on Github if you like it! The code for this project can be found here:
4
+
5
+ - [Github](https://github.com/Borg93/htr_gradio)
6
+ **Note**: We will in the future package all of the code for mass htr (batch inference on multi-GPU setup), but the code is still work in progress.
7
+
8
+ ## Models
9
+
10
+ The models within this pipeline will be subject to continual retraining and updates as more data becomes accessible. For detailed information about all the models used in this project, please refer to the model cards available on Hugging Face:
11
+
12
+ - [Riksarkivet/rtmdet_regions](https://huggingface.co/Riksarkivet/rtmdet_regions)
13
+ - [Riksarkivet/rtmdet_lines](https://huggingface.co/Riksarkivet/rtmdet_lines)
14
+ - [Riksarkivet/satrn_htr](https://huggingface.co/https://huggingface.co/Riksarkivet/satrn_htr)
15
+
16
+ ## Datasets
17
+
18
+ Both train and evaluation datasets for the models will be released in the future here:
19
+
20
+ - [Riksarkivet/placeholder_region_segmentation](https://huggingface.co/datasets/Riksarkivet/placeholder_region_segmentation)
21
+ - [Riksarkivet/placeholder_line_segmentation](https://huggingface.co/datasets/Riksarkivet/placeholder_line_segmentation)
22
+ - [Riksarkivet/placeholder_htr](https://huggingface.co/datasets/Riksarkivet/placeholder_htr)
helper/text/about/htrflow/htrflow_row1.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ## The Pipeline in Overview
2
+
3
+ The steps in the pipeline can be seen below as follows:
helper/text/about/htrflow/htrflow_tab1.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ### Binarization
2
+
3
+ The reason for binarizing the images before processing them is that we want the models to generalize as well as possible. 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. The pipeline implements a simple adaptive thresholding algorithm for binarization.
4
+
5
+ <figure>
6
+ <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_bin.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
7
+ </figure>
helper/text/about/htrflow/htrflow_tab2.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ### Text-region segmentation
2
+
3
+ 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. 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. 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.
4
+
5
+ <figure>
6
+ <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_region.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
7
+ </figure>
helper/text/about/htrflow/htrflow_tab3.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ### Text-line segmentation
2
+
3
+ This is also an RTMDet model that's trained on extracting text-lines from cropped text-regions within an image. The same post-processing on the instance segmentation masks is done here as in the text-region segmentation step.
4
+
5
+ <figure>
6
+ <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_line.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
7
+ </figure>
helper/text/about/htrflow/htrflow_tab4.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ### HTR
2
+
3
+ For the text-recognition a SATRN model was trained with mmocr on approximately one million handwritten text-line images ranging from 1600 to 1900. 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.
4
+
5
+ <figure>
6
+ <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_htr.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
7
+ </figure>
helper/text/docs_strucutre.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Instructions for documentation
2
+
3
+ - Naming convention of folder is based on tab
4
+ - Naming convention of file is based on subtabs
5
+ - If subtab uses columns and rows
6
+ - Use suffix such as col1, row1 or tab1, to indicate differences in postion of text.
7
+
8
+ see image below:
9
+
10
+ <p align="center">
11
+ <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/layout_structure.png?raw=true" alt="Badge 1">
12
+ </p>
13
+
14
+ ## Assets and file sharing with app
15
+
16
+ This repo acts as asset manager for the app:
17
+
18
+ - [Github Repo](https://github.com/Borg93/htr_gradio_file_placeholder)
19
+
20
+ **Note**: this repo is an work in progress
helper/text/help/faq.md DELETED
@@ -1,9 +0,0 @@
1
- ## Frequently asked questions
2
-
3
- WIP
4
-
5
- **Q**: <u>Is my data secure?</u>
6
- **A**: Absolutely. We prioritize user data security and have implemented robust encryption methods to ensure your data remains private and protected.
7
-
8
- **Q**: <u>Who can I contact for technical support?</u>
9
- **A**: Please reach out to our support team at [email protected] for any technical queries.
 
 
 
 
 
 
 
 
 
 
helper/text/help/faq_discussion/discussion.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Discussion about the app
2
+
3
+ If you have suggestions, questions, or would like to discuss improvemnts for the app, please don't hesitate to reach out.
4
+
5
+ - Open a discussion on [HuggingFace](https://huggingface.co/spaces/Riksarkivet/htr_demo/discussions).
6
+
7
+ ## Contact us
8
+
9
+ If you prefer email or your question is more sensitive please email.
10
+
11
+ - Send it to [email protected]
helper/text/help/faq_discussion/faq.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Frequently Asked Questions
2
+
3
+ **Q**: <u>Is my data secure? Can I upload my own images?</u>
4
+ **A**: Absolutely. Uploaded files are not saved or stored.
5
+
6
+ **Q**: <u>Why am I always in a queue?</u>
7
+ **A**: This is due to hardware constraints and rate limits imposed by Hugging Face. For alternative ways to use the app, refer to the **Documentation** tab under **Duplication for Own Use & API**.
8
+
9
+ **Q**: <u>Why is inference slow?</u>
10
+ **A**: The current speed is due to hardware limitations and the present state of the code. However, we plan to update the application in future releases, which will significantly improve inference times.
11
+
12
+ **Q**: <u>Is batch inference possible?</u>
13
+ **A**: Not currently, but we plan to add this feature in the future.
helper/text/help/{fast_track.md → fasttrack/fast_track.md} RENAMED
File without changes
helper/text/help/{stepwise.md → stepwise/stepwise.md} RENAMED
File without changes
helper/text/text_about.py CHANGED
@@ -1,78 +1,31 @@
1
- class TextAbout:
2
- # About text
3
- intro_text = """
4
-
5
- ## Introduction
6
- The Swedish National Archives introduces a demonstrational end-to-end HTR (Handwritten Text Recognition) pipeline. This pipeline comprises two instance segmentation models: one designated for segmenting text-regions and another for isolating text-lines within these regions, coupled with an HTR model for image-to-text transcription. The objective of this project is to establish a generic pipeline capable of processing running-text documents spanning from 1600 to 1900.
7
 
8
- ## Usage
9
- It's crucial to emphasize that this application serves primarily for demonstration purposes, aimed at showcasing the various models employed in the current workflow for processing documents with running-text. <br>
10
 
11
- For an insight into the upcoming features we are working on:
12
- - Navigate to the > **About** > **Roadmap**.
 
13
 
14
- To understand how to utilize this application through a REST API, self-host or via Docker,
15
- - Navigate to the > **About** > **How to Use** > **API & Duplicate for Private Use**.
16
-
17
- """
18
 
19
- ## The Pipeline in Overview
20
- pipeline_overview_text = """
21
- ## The Pipeline in Overview
22
-
23
- The steps in the pipeline can be seen below as follows:
24
- """
25
 
26
- binarization = """
27
 
28
- ### Binarization
29
- The reason for binarizing the images before processing them is that we want the models to generalize as well as possible. 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. The pipeline implements a simple adaptive thresholding algorithm for binarization.
30
- <figure>
31
- <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_bin.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
32
- </figure>
33
 
34
- """
35
- text_region_segment = """
36
- ### Text-region segmentation
37
- 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. 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. 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.
38
- <figure>
39
- <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_region.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
40
- </figure>
41
- """
42
- text_line_segmentation = """
43
- ### Text-line segmentation
44
 
45
- This is also an RTMDet model that's trained on extracting text-lines from cropped text-regions within an image. The same post-processing on the instance segmentation masks is done here as in the text-region segmentation step.
46
- <figure>
47
- <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_line.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
48
- </figure>
49
- """
50
- text_htr = """
51
- ### HTR
52
 
53
- For the text-recognition a SATRN model was trained with mmocr on approximately one million handwritten text-line images ranging from 1600 to 1900. 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.
54
- <figure>
55
- <img src="https://github.com/Borg93/htr_gradio_file_placeholder/blob/main/app_project_htr.png?raw=true" alt="HTR_tool" style="width:70%; display: block; margin-left: auto; margin-right:auto;" >
56
- </figure>
57
- """
58
 
59
- text_src_code_data_models = """
60
- ## Source Code
61
- Please fork and leave a star on Github if you like it! The code for this project can be found here:
62
- - [Github](https://github.com/Borg93/htr_gradio)
63
- **Note**: We will in the future package all of the code for mass htr (batch inference on multi-GPU setup), but the code is still work in progress.
64
 
65
- ## The Dataset
66
- For a glimpse into the kind of data we're working with, you can explore our sample test data on Hugging Face:
67
- - [HuggingFace Dataset Card](https://huggingface.co/datasets/Riksarkivet/test_images_demo)
68
- **Note**: This is just a sample. The complete training dataset will be released in the future.
69
 
70
- ## The Models
71
- The models within this pipeline will be subject to continual retraining and updates as more data becomes accessible. For detailed information about all the models used in this project, please refer to the model cards available on Hugging Face:
72
- - [Riksarkivet/rtmdet_regions](https://huggingface.co/Riksarkivet/rtmdet_regions)
73
- - [Riksarkivet/rtmdet_lines](https://huggingface.co/Riksarkivet/rtmdet_lines)
74
- - [Riksarkivet/satrn_htr](https://huggingface.co/https://huggingface.co/Riksarkivet/satrn_htr)
75
- """
76
 
77
 
78
  if __name__ == "__main__":
 
1
+ from helper.text.markdown_reader import read_markdown
 
 
 
 
 
2
 
 
 
3
 
4
+ class TextAbout:
5
+ # HTRFLOW
6
+ htrflow_col1 = read_markdown("helper/text/about/htrflow/htrflow_col1.md")
7
 
8
+ htrflow_col2 = read_markdown("helper/text/about/htrflow/htrflow_col2.md")
 
 
 
9
 
10
+ htrflow_row1 = read_markdown("helper/text/about/htrflow/htrflow_row1.md")
 
 
 
 
 
11
 
12
+ htrflow_tab1 = read_markdown("helper/text/about/htrflow/htrflow_tab1.md")
13
 
14
+ htrflow_tab2 = read_markdown("helper/text/about/htrflow/htrflow_tab2.md")
 
 
 
 
15
 
16
+ htrflow_tab3 = read_markdown("helper/text/about/htrflow/htrflow_tab3.md")
 
 
 
 
 
 
 
 
 
17
 
18
+ htrflow_tab4 = read_markdown("helper/text/about/htrflow/htrflow_tab4.md")
 
 
 
 
 
 
19
 
20
+ # Contributions
21
+ contributions = read_markdown("helper/text/about/contributions/contributions.md")
 
 
 
22
 
23
+ # Changelog & Roadmap
24
+ current_changelog = read_markdown("helper/text/about/changelog_roadmap/current_changelog.md")
 
 
 
25
 
26
+ old_changelog = read_markdown("helper/text/about/changelog_roadmap/old_changelog.md")
 
 
 
27
 
28
+ roadmap = read_markdown("helper/text/about/changelog_roadmap/roadmap.md")
 
 
 
 
 
29
 
30
 
31
  if __name__ == "__main__":
helper/text/text_app.py CHANGED
@@ -1,16 +1,17 @@
1
  class TextApp:
2
- demo_version = """Demo version 0.0.1"""
3
 
4
  title_markdown = """
5
 
6
 
7
  <h1><center> HTRFLOW </center></h1>
8
 
9
- <h3><center> Swedish National Archives - Riksarkivet </center></h3>"""
10
 
11
  title_markdown_img = """
12
- <img src="https://raw.githubusercontent.com/Borg93/Riksarkivet_docs/main/docs/assets/fav-removebg-preview.png" width="13%" align="right" margin-right="100" />
13
-
 
14
  """
15
 
16
 
 
1
  class TextApp:
2
+ demo_version = """<em>Version 0.0.1</em>"""
3
 
4
  title_markdown = """
5
 
6
 
7
  <h1><center> HTRFLOW </center></h1>
8
 
9
+ <p><center>Explore AI models for historical HTR developed by the Swedish National Archives </center></p>"""
10
 
11
  title_markdown_img = """
12
+ <a href="https://riksarkivet.se">
13
+ <img src="https://raw.githubusercontent.com/Borg93/Riksarkivet_docs/main/docs/assets/fav-removebg-preview.png" width="17%" align="right" margin-right="100" />
14
+ </a>
15
  """
16
 
17
 
helper/text/text_help.py CHANGED
@@ -46,8 +46,16 @@ Follow the instructions below:
46
  htr_tool_api_text = """
47
  ## Usage of Client API
48
 
49
- For those interested in testing out the demo, it's available to run as a Gradio Python client. To facilitate this, there's a lightweight package called ´gradio_client´ that you can easily install via pip.
50
- """
 
 
 
 
 
 
 
 
51
 
52
  stepwise_htr_tool_tab1 = """
53
  ### Tab 1: Region Segmentation
@@ -121,16 +129,18 @@ Alternatively, you can watch the instructional video below, which provides a ste
121
  </figure>
122
  """
123
  duplicatin_space_htr_text = """
124
- ## Duplicating for own Use
125
 
126
- It's worth noting that while using any poublic Space as an API is possible, there's a catch. Hugging Face might rate limit you if you send an excessive number of requests in a short period. However, there's a workaround for those who need to make frequent API calls. By duplicating a public Space, you can create your own private Space. This private version allows you to make unlimited requests without any restrictions. So, if you're planning on heavy usage duplicate space:
 
 
 
 
 
 
 
 
127
 
128
- <br>
129
- <p align="center">
130
- <a href="https://huggingface.co/spaces/Riksarkivet/htr_demo?duplicate=true">
131
- <img src="https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-xl-dark.svg" alt="Badge 1">
132
- </a>
133
- </p>
134
  """
135
 
136
  duplicatin_for_privat = """
@@ -158,7 +168,7 @@ print(job.result())
158
  output_code_for_api_text = """
159
  ### Output from the api
160
 
161
- The output from the api is currently in the format of Page XML, which can be imported into transkibus or be viewed in this [viewer](https://huggingface.co/spaces/Riksarkivet/Viewer_demo).
162
 
163
 
164
  """
@@ -193,31 +203,13 @@ Loaded as API: http://127.0.0.1:7860/ ✔
193
  # Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
194
  """
195
 
196
- text_faq = read_markdown("helper/text/help/faq.md")
197
 
198
  text_contact = """
199
 
200
  """
201
 
202
- discussion = """
203
- ## Discussion about the app
204
-
205
- If you have suggestions, questions, or would like to discuss our roadmap further, please don't hesitate to reach out.
206
- Press badge below to open a discussion on HuggingFace.
207
-
208
- <p align="center">
209
- <a href="https://huggingface.co/spaces/Riksarkivet/htr_demo/discussions">
210
- <img src="https://huggingface.co/datasets/huggingface/badges/raw/main/open-a-discussion-xl-dark.svg" alt="Badge 1">
211
- </a>
212
- </p>
213
-
214
- ## Open discussion
215
- DIGG...
216
-
217
- ## Contact us
218
- email..
219
-
220
- """
221
 
222
 
223
  if __name__ == "__main__":
 
46
  htr_tool_api_text = """
47
  ## Usage of Client API
48
 
49
+ If you prefer to run **Fast track** programmatically, we offer an API for that purpose.
50
+
51
+ - Docuemtnation for gradio client with [python](https://www.gradio.app/guides/getting-started-with-the-python-client)
52
+ - Docuemtnation for gradio client with [javascript](https://www.gradio.app/guides/getting-started-with-the-js-client)
53
+
54
+ **Note**: More extensive APIs and documentation can be added in the future upon request.
55
+
56
+ See example below for usage of API in python:
57
+
58
+ """
59
 
60
  stepwise_htr_tool_tab1 = """
61
  ### Tab 1: Region Segmentation
 
129
  </figure>
130
  """
131
  duplicatin_space_htr_text = """
132
+ ## Duplicating for own use
133
 
134
+ Please be aware of certain limitations when using the application:
135
+ - Primarily, this application is designed for demonstration purposes and is not intended for mass HTR.
136
+ - Currently, the Swedish National Archives has constraints on sharing hardware, leading to a queue system for high demand.
137
+ - The demo is hosted on Hugging Face domains, and they may rate-limit you if there's an excessive number of requests in a short timeframe, especially when using the API.
138
+
139
+ For those requiring heavy usage, you can conveniently duplicate the application.
140
+ - Duplicate [application](https://huggingface.co/spaces/Riksarkivet/htr_demo?duplicate=true).
141
+
142
+ By doing so, you'll create your own private app, which allows for unlimited requests without any restrictions. The image below shows the minimum hardware you need to use if you don't have access to hardware youself:
143
 
 
 
 
 
 
 
144
  """
145
 
146
  duplicatin_for_privat = """
 
168
  output_code_for_api_text = """
169
  ### Output from the api
170
 
171
+ The output from the api is currently in the format of Page XML, which can be imported into this [viewer](https://huggingface.co/spaces/Riksarkivet/Viewer_demo).
172
 
173
 
174
  """
 
203
  # Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
204
  """
205
 
206
+ text_faq = read_markdown("helper/text/help/faq_discussion/faq.md")
207
 
208
  text_contact = """
209
 
210
  """
211
 
212
+ text_discussion = read_markdown("helper/text/help/faq_discussion/discussion.md")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
 
215
  if __name__ == "__main__":
tabs/about_tab.py CHANGED
@@ -1,39 +1,71 @@
1
  import gradio as gr
2
 
3
  from helper.text.text_about import TextAbout
4
- from helper.text.text_roadmap import TextRoadmap
5
 
6
  with gr.Blocks() as about_tab:
7
  with gr.Tabs():
8
  with gr.Tab("HTRFLOW"):
9
  with gr.Row():
10
  with gr.Column():
11
- gr.Markdown(TextAbout.intro_text)
12
  with gr.Column():
13
- gr.Markdown(TextAbout.text_src_code_data_models)
14
  with gr.Row():
15
- gr.Markdown(TextAbout.pipeline_overview_text)
16
  with gr.Row():
17
  with gr.Tabs():
18
  with gr.Tab("Binarization"):
19
- gr.Markdown(TextAbout.binarization)
20
  with gr.Tab("Region segmentation"):
21
- gr.Markdown(TextAbout.text_region_segment)
22
  with gr.Tab("Line segmentation"):
23
- gr.Markdown(TextAbout.text_line_segmentation)
24
  with gr.Tab("Text recognition"):
25
- gr.Markdown(TextAbout.text_htr)
 
 
 
 
 
 
 
26
 
27
  with gr.Tab("Contributions"):
28
  with gr.Row():
29
- gr.Markdown(TextRoadmap.text_contribution)
30
 
31
  with gr.Tab("Changelog & Roadmap"):
32
  with gr.Row():
33
  with gr.Column():
34
  with gr.Accordion("Current Changelog", open=True):
35
- gr.Markdown(TextRoadmap.changelog)
36
  with gr.Accordion("Old Changelog", open=False):
37
- pass
38
  with gr.Column():
39
- gr.Markdown(TextRoadmap.roadmap)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
  from helper.text.text_about import TextAbout
4
+ from helper.text.text_help import TextHowTo
5
 
6
  with gr.Blocks() as about_tab:
7
  with gr.Tabs():
8
  with gr.Tab("HTRFLOW"):
9
  with gr.Row():
10
  with gr.Column():
11
+ gr.Markdown(TextAbout.htrflow_col1)
12
  with gr.Column():
13
+ gr.Markdown(TextAbout.htrflow_col2)
14
  with gr.Row():
15
+ gr.Markdown(TextAbout.htrflow_row1)
16
  with gr.Row():
17
  with gr.Tabs():
18
  with gr.Tab("Binarization"):
19
+ gr.Markdown(TextAbout.htrflow_tab1)
20
  with gr.Tab("Region segmentation"):
21
+ gr.Markdown(TextAbout.htrflow_tab2)
22
  with gr.Tab("Line segmentation"):
23
+ gr.Markdown(TextAbout.htrflow_tab3)
24
  with gr.Tab("Text recognition"):
25
+ gr.Markdown(TextAbout.htrflow_tab4)
26
+
27
+ with gr.Tab("FAQ & Discussion"):
28
+ with gr.Row():
29
+ with gr.Column():
30
+ gr.Markdown(TextHowTo.text_faq)
31
+ with gr.Column():
32
+ gr.Markdown(TextHowTo.text_discussion)
33
 
34
  with gr.Tab("Contributions"):
35
  with gr.Row():
36
+ gr.Markdown(TextAbout.contributions)
37
 
38
  with gr.Tab("Changelog & Roadmap"):
39
  with gr.Row():
40
  with gr.Column():
41
  with gr.Accordion("Current Changelog", open=True):
42
+ gr.Markdown(TextAbout.current_changelog)
43
  with gr.Accordion("Old Changelog", open=False):
44
+ gr.Markdown(TextAbout.old_changelog)
45
  with gr.Column():
46
+ gr.Markdown(TextAbout.roadmap)
47
+
48
+ with gr.Tab("Duplicating for own use & API"):
49
+ with gr.Row():
50
+ with gr.Column():
51
+ gr.Markdown(TextHowTo.duplicatin_space_htr_text)
52
+ gr.Markdown(TextHowTo.figure_htr_hardware)
53
+ gr.Markdown(TextHowTo.duplicatin_for_privat)
54
+
55
+ with gr.Column():
56
+ gr.Markdown(TextHowTo.htr_tool_api_text)
57
+ gr.Code(
58
+ value=TextHowTo.code_for_api,
59
+ language="python",
60
+ interactive=False,
61
+ show_label=False,
62
+ )
63
+
64
+ gr.Markdown(TextHowTo.output_code_for_api_text)
65
+
66
+ gr.Code(
67
+ value=TextHowTo.output_code_for_api,
68
+ language=None,
69
+ interactive=False,
70
+ show_label=False,
71
+ )
tabs/help_tab.py CHANGED
@@ -4,13 +4,6 @@ from helper.text.text_help import TextHowTo
4
 
5
  with gr.Blocks() as help_tab:
6
  with gr.Tabs():
7
- with gr.Tab("FAQ & Discussion"):
8
- with gr.Row():
9
- with gr.Column():
10
- gr.Markdown(TextHowTo.text_faq)
11
- with gr.Column():
12
- gr.Markdown(TextHowTo.discussion)
13
-
14
  with gr.Tab("Fast track"):
15
  gr.Markdown("WIP")
16
  pass
@@ -47,33 +40,3 @@ with gr.Blocks() as help_tab:
47
  gr.Markdown("image")
48
  with gr.Row():
49
  gr.Markdown(TextHowTo.stepwise_htr_tool_end)
50
-
51
- with gr.Tab("API"):
52
- with gr.Row():
53
- with gr.Column():
54
- gr.Markdown(TextHowTo.htr_tool_api_text)
55
- gr.Code(
56
- value=TextHowTo.code_for_api,
57
- language="python",
58
- interactive=False,
59
- show_label=False,
60
- )
61
- with gr.Column():
62
- gr.Markdown(TextHowTo.output_code_for_api_text)
63
-
64
- gr.Code(
65
- value=TextHowTo.output_code_for_api,
66
- language=None,
67
- interactive=False,
68
- show_label=False,
69
- )
70
-
71
- pass
72
- with gr.Tab("Duplicating for own use"):
73
- with gr.Row():
74
- with gr.Column():
75
- gr.Markdown(TextHowTo.duplicatin_space_htr_text)
76
- gr.Markdown(TextHowTo.figure_htr_hardware)
77
-
78
- with gr.Column():
79
- gr.Markdown(TextHowTo.duplicatin_for_privat)
 
4
 
5
  with gr.Blocks() as help_tab:
6
  with gr.Tabs():
 
 
 
 
 
 
 
7
  with gr.Tab("Fast track"):
8
  gr.Markdown("WIP")
9
  pass
 
40
  gr.Markdown("image")
41
  with gr.Row():
42
  gr.Markdown(TextHowTo.stepwise_htr_tool_end)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tabs/htr_tool.py CHANGED
@@ -45,12 +45,13 @@ with gr.Blocks() as htr_tool_tab:
45
 
46
  with gr.Tab("Visualize") as tab_image_viewer_selector:
47
  with gr.Row():
48
- gr.Button(
49
- value="Image viewer",
50
- variant="secondary",
51
- link="https://huggingface.co/spaces/Riksarkivet/Viewer_demo",
52
- interactive=True,
53
- )
 
54
 
55
  run_image_visualizer_button = gr.Button(
56
  value="Visualize results", variant="primary", interactive=True
@@ -63,7 +64,12 @@ with gr.Blocks() as htr_tool_tab:
63
  with gr.Tab("Compare") as tab_model_compare_selector:
64
  with gr.Box():
65
  gr.Markdown(
66
- "Compare different runs with uploaded Ground Truth and calculate CER. You will also be able to upload output format files"
 
 
 
 
 
67
  )
68
 
69
  calc_cer_button_fast = gr.Button("Calculate CER", variant="primary", visible=True)
@@ -80,82 +86,85 @@ with gr.Blocks() as htr_tool_tab:
80
  examples_per_page=5,
81
  )
82
 
 
 
83
  with gr.Column(scale=3):
84
- with gr.Row():
85
- with gr.Group():
86
- gr.Markdown(" &nbsp; ⚙️ Settings ")
87
- with gr.Row():
88
- radio_file_input = gr.CheckboxGroup(
89
- choices=["Txt", "Page XML"],
90
- value=["Txt", "Page XML"],
91
- label="Output file extension",
92
- # info="Only txt and page xml is supported for now!",
93
- scale=1,
94
- )
95
- with gr.Row():
96
- gr.Checkbox(
97
- value=True,
98
- label="Binarize image",
99
- info="Binarize image to reduce background noise",
100
- )
101
- gr.Checkbox(
102
- value=True,
103
- label="Output prediction threshold",
104
- info="Output XML with prediction score",
105
- )
106
-
107
- with gr.Accordion("Models", open=False):
108
- with gr.Group():
109
- with gr.Row():
110
- htr_tool_region_segment_model_dropdown = gr.Dropdown(
111
- choices=["Riksarkivet/rtmdet_region"],
112
- value="Riksarkivet/rtmdet_region",
113
- label="Region segmentation models",
114
- info="More models will be added",
115
- )
116
-
117
- gr.Slider(
118
- minimum=0.4,
119
- maximum=1,
120
- value=0.5,
121
- step=0.05,
122
- label="P-threshold",
123
- info="""Filter confidence score for a prediction score to be considered""",
124
- )
125
-
126
- with gr.Row():
127
- htr_tool_line_segment_model_dropdown = gr.Dropdown(
128
- choices=["Riksarkivet/rtmdet_lines"],
129
- value="Riksarkivet/rtmdet_lines",
130
- label="Line segmentation models",
131
- info="More models will be added",
132
- )
133
-
134
- gr.Slider(
135
- minimum=0.4,
136
- maximum=1,
137
- value=0.5,
138
- step=0.05,
139
- label="P-threshold",
140
- info="""Filter confidence score for a prediction score to be considered""",
141
- )
142
-
143
- with gr.Row():
144
- htr_tool_transcriber_model_dropdown = gr.Dropdown(
145
- choices=["Riksarkivet/satrn_htr", "microsoft/trocr-base-handwritten"],
146
- value="Riksarkivet/satrn_htr",
147
- label="Text recognition models",
148
- info="More models will be added",
149
- )
150
-
151
- gr.Slider(
152
- value=0.6,
153
- minimum=0.5,
154
- maximum=1,
155
- label="HTR threshold",
156
- info="Prediction score threshold for transcribed lines",
157
- scale=1,
158
- )
 
159
 
160
  with gr.Row(visible=False) as image_viewer_tab:
161
  text_polygon_dict = gr.Variable()
@@ -169,7 +178,7 @@ with gr.Blocks() as htr_tool_tab:
169
  gr.Radio(
170
  choices=["Compare Page XML", "Compare different runs"],
171
  value="Compare Page XML",
172
- info="Compare different runs from HTRFLOW or with external runs, e.g with Transkibus ",
173
  )
174
  with gr.Row():
175
  gr.UploadButton(label="Run A")
 
45
 
46
  with gr.Tab("Visualize") as tab_image_viewer_selector:
47
  with gr.Row():
48
+ gr.Markdown("")
49
+ # gr.Button(
50
+ # value="Image viewer",
51
+ # variant="secondary",
52
+ # link="https://huggingface.co/spaces/Riksarkivet/Viewer_demo",
53
+ # interactive=True,
54
+ # )
55
 
56
  run_image_visualizer_button = gr.Button(
57
  value="Visualize results", variant="primary", interactive=True
 
64
  with gr.Tab("Compare") as tab_model_compare_selector:
65
  with gr.Box():
66
  gr.Markdown(
67
+ """
68
+ **Work in progress**
69
+
70
+ Compare different runs with uploaded Ground Truth and calculate CER. You will also be able to upload output format files
71
+
72
+ """
73
  )
74
 
75
  calc_cer_button_fast = gr.Button("Calculate CER", variant="primary", visible=True)
 
86
  examples_per_page=5,
87
  )
88
 
89
+ gr.Markdown("&nbsp;")
90
+
91
  with gr.Column(scale=3):
92
+ with gr.Group():
93
+ gr.Markdown(" &nbsp; ⚙️ Settings ")
94
+ with gr.Row():
95
+ radio_file_input = gr.CheckboxGroup(
96
+ choices=["Txt", "Page XML"],
97
+ value=["Txt", "Page XML"],
98
+ label="Output file extension",
99
+ info="JSON and ALTO-XML will be added",
100
+ scale=1,
101
+ )
102
+ with gr.Row():
103
+ gr.Checkbox(
104
+ value=True,
105
+ label="Binarize image",
106
+ info="Binarize image to reduce background noise",
107
+ )
108
+ gr.Checkbox(
109
+ value=True,
110
+ label="Output prediction threshold",
111
+ info="Output XML with prediction score",
112
+ )
113
+
114
+ with gr.Accordion("Advanced settings", open=False):
115
+ with gr.Group():
116
+ with gr.Row():
117
+ htr_tool_region_segment_model_dropdown = gr.Dropdown(
118
+ choices=["Riksarkivet/rtmdet_region"],
119
+ value="Riksarkivet/rtmdet_region",
120
+ label="Region segmentation models",
121
+ info="More models will be added",
122
+ )
123
+
124
+ gr.Slider(
125
+ minimum=0.4,
126
+ maximum=1,
127
+ value=0.5,
128
+ step=0.05,
129
+ label="P-threshold",
130
+ info="""Filter confidence score for a prediction score to be considered""",
131
+ )
132
+
133
+ with gr.Row():
134
+ htr_tool_line_segment_model_dropdown = gr.Dropdown(
135
+ choices=["Riksarkivet/rtmdet_lines"],
136
+ value="Riksarkivet/rtmdet_lines",
137
+ label="Line segmentation models",
138
+ info="More models will be added",
139
+ )
140
+
141
+ gr.Slider(
142
+ minimum=0.4,
143
+ maximum=1,
144
+ value=0.5,
145
+ step=0.05,
146
+ label="P-threshold",
147
+ info="""Filter confidence score for a prediction score to be considered""",
148
+ )
149
+
150
+ with gr.Row():
151
+ htr_tool_transcriber_model_dropdown = gr.Dropdown(
152
+ choices=["Riksarkivet/satrn_htr", "microsoft/trocr-base-handwritten"],
153
+ value="Riksarkivet/satrn_htr",
154
+ label="Text recognition models",
155
+ info="More models will be added",
156
+ )
157
+
158
+ gr.Slider(
159
+ value=0.6,
160
+ minimum=0.5,
161
+ maximum=1,
162
+ label="HTR threshold",
163
+ info="Prediction score threshold for transcribed lines",
164
+ scale=1,
165
+ )
166
+ with gr.Row():
167
+ gr.Markdown(" &nbsp; More settings will be added")
168
 
169
  with gr.Row(visible=False) as image_viewer_tab:
170
  text_polygon_dict = gr.Variable()
 
178
  gr.Radio(
179
  choices=["Compare Page XML", "Compare different runs"],
180
  value="Compare Page XML",
181
+ info="Compare different runs from HTRFLOW or with external runs.",
182
  )
183
  with gr.Row():
184
  gr.UploadButton(label="Run A")
tabs/stepwise_htr_tool.py CHANGED
@@ -141,12 +141,12 @@ with gr.Blocks() as stepwise_htr_tool_tab:
141
  info="More models will be added",
142
  )
143
  with gr.Row():
144
- clear_line_segment_button = gr.Button(
145
- " ",
146
- variant="Secondary",
147
- # elem_id="center_button",
148
- scale=1,
149
- )
150
 
151
  line_segment_button = gr.Button(
152
  "Run",
@@ -156,8 +156,6 @@ with gr.Blocks() as stepwise_htr_tool_tab:
156
  )
157
 
158
  with gr.Column(scale=3):
159
- # gr.Markdown("""lorem ipsum""")
160
-
161
  output_line_from_region = gr.Image(
162
  label="Segmented lines", type="numpy", interactive="False", height=600
163
  )
@@ -199,7 +197,7 @@ with gr.Blocks() as stepwise_htr_tool_tab:
199
  )
200
 
201
  with gr.Row():
202
- clear_transcribe_button = gr.Button(" ", variant="Secondary", visible=True, scale=1)
203
 
204
  transcribe_button = gr.Button("Run", variant="primary", visible=True, scale=1)
205
 
@@ -211,6 +209,7 @@ with gr.Blocks() as stepwise_htr_tool_tab:
211
  lines=26,
212
  value="",
213
  show_copy_button=True,
 
214
  )
215
 
216
  #####################################
@@ -261,6 +260,7 @@ with gr.Blocks() as stepwise_htr_tool_tab:
261
 
262
  with gr.Row(equal_height=False):
263
  cer_output = gr.Textbox(label="CER:")
 
264
  calc_cer_button = gr.Button("Calculate CER", variant="primary", visible=True)
265
 
266
  with gr.Column(scale=1, visible=True):
@@ -283,7 +283,7 @@ with gr.Blocks() as stepwise_htr_tool_tab:
283
 
284
  def compute_cer(dataframe_text_index, gt_text_index):
285
  if gt_text_index is not None and gt_text_index.strip() != "":
286
- return cer_metric.compute(predictions=[dataframe_text_index], references=[gt_text_index])
287
  else:
288
  return "Ground truth not provided"
289
 
@@ -324,6 +324,8 @@ with gr.Blocks() as stepwise_htr_tool_tab:
324
  ],
325
  )
326
 
 
 
327
  transcribe_button.click(
328
  custom_track.transcribe_text,
329
  inputs=[inputs_lines_to_transcribe],
 
141
  info="More models will be added",
142
  )
143
  with gr.Row():
144
+ # placeholder_line_button = gr.Button(
145
+ # "",
146
+ # variant="secondary",
147
+ # scale=1,
148
+ # )
149
+ gr.Markdown("&nbsp;")
150
 
151
  line_segment_button = gr.Button(
152
  "Run",
 
156
  )
157
 
158
  with gr.Column(scale=3):
 
 
159
  output_line_from_region = gr.Image(
160
  label="Segmented lines", type="numpy", interactive="False", height=600
161
  )
 
197
  )
198
 
199
  with gr.Row():
200
+ copy_textarea = gr.Button("Copy Text", variant="secondary", visible=True, scale=1)
201
 
202
  transcribe_button = gr.Button("Run", variant="primary", visible=True, scale=1)
203
 
 
209
  lines=26,
210
  value="",
211
  show_copy_button=True,
212
+ elem_id="textarea_stepwise_3",
213
  )
214
 
215
  #####################################
 
260
 
261
  with gr.Row(equal_height=False):
262
  cer_output = gr.Textbox(label="CER:")
263
+ gr.Markdown("")
264
  calc_cer_button = gr.Button("Calculate CER", variant="primary", visible=True)
265
 
266
  with gr.Column(scale=1, visible=True):
 
283
 
284
  def compute_cer(dataframe_text_index, gt_text_index):
285
  if gt_text_index is not None and gt_text_index.strip() != "":
286
+ return round(cer_metric.compute(predictions=[dataframe_text_index], references=[gt_text_index]), 4)
287
  else:
288
  return "Ground truth not provided"
289
 
 
324
  ],
325
  )
326
 
327
+ copy_textarea.click(fn=None, _js="""document.querySelector("#textarea_stepwise_3 > label > button").click()""")
328
+
329
  transcribe_button.click(
330
  custom_track.transcribe_text,
331
  inputs=[inputs_lines_to_transcribe],