Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- Riksarkivet/trolldomskommissionen_seg
|
4 |
+
- Riksarkivet/svea_hovratt_seg
|
5 |
+
- Riksarkivet/krigshovrattens_dombocker_seg
|
6 |
+
- Riksarkivet/jonkopings_radhusratts_och_magistrat_seg
|
7 |
+
- Riksarkivet/gota_hovratt_seg
|
8 |
+
- Riksarkivet/frihetstidens_utskottshandlingar_seg
|
9 |
+
- Riksarkivet/bergskollegium_relationer_och_skrivelser_seg
|
10 |
+
- Riksarkivet/bergskollegium_advokatfiskalskontoret_seg
|
11 |
+
tags:
|
12 |
+
- instance segmentation
|
13 |
+
- text regions
|
14 |
+
- handwritten
|
15 |
+
- htr
|
16 |
+
---
|
17 |
+
|
18 |
+
# Yolov9-textregions-handwritten
|
19 |
+
|
20 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
21 |
+
|
22 |
+
A yolov9 instance segmentation model for segmenting text-regions in handwritten running-text documents
|
23 |
+
|
24 |
+
|
25 |
+
## Model Details
|
26 |
+
|
27 |
+
### Model Description
|
28 |
+
|
29 |
+
This model was developed for segmenting text-regions in handwritten running-text documents. It is meant to be implemented in an HTR-pipeline
|
30 |
+
where one first segment text-regions, then text-lines within the regions, and then feed these text-lines to an HTR-model.
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
- **Developed by:** The Swedish National Archives
|
35 |
+
- **Model type:** yolov9
|
36 |
+
- **License:** [More Information Needed]
|
37 |
+
|
38 |
+
### Model Sources [optional]
|
39 |
+
|
40 |
+
|
41 |
+
- **Repository:** [yolov9-regions-1](https://huggingface.co/Riksarkivet/yolov9-regions-1)
|
42 |
+
- **Paper [optional]:** [YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information](https://arxiv.org/abs/2402.13616)
|
43 |
+
|
44 |
+
## Uses
|
45 |
+
|
46 |
+
|
47 |
+
### Direct Use
|
48 |
+
|
49 |
+
Segment text-regions in handwritten running-text documents
|
50 |
+
|
51 |
+
### Downstream Use [optional]
|
52 |
+
|
53 |
+
As part of an HTR-pipeline for transcribing entire pages of handwritten running-text documents. See [Swedish Lion Libre](https://huggingface.co/Riksarkivet/trocr-base-handwritten-hist-swe-2)
|
54 |
+
for example usage with the [HTRflow package](https://github.com/AI-Riksarkivet/htrflow)
|
55 |
+
|
56 |
+
|
57 |
+
## How to Get Started with the Model
|
58 |
+
|
59 |
+
### How to Load and Use the YOLOv9 Instance Segmentation Model
|
60 |
+
|
61 |
+
Below is the Python code to load and use the trained YOLOv9 instance segmentation model using the Ultralytics repo:
|
62 |
+
|
63 |
+
```python
|
64 |
+
import torch
|
65 |
+
from ultralytics import YOLO
|
66 |
+
|
67 |
+
# Load the trained YOLOv9 model
|
68 |
+
model = YOLO('path/to/your/model.pt') # Update with the correct path to your trained model
|
69 |
+
|
70 |
+
# Load an image
|
71 |
+
img = 'path/to/your/image.jpg' # Update with the path to the image you want to use
|
72 |
+
|
73 |
+
# Perform instance segmentation
|
74 |
+
results = model(img)
|
75 |
+
|
76 |
+
# Display results
|
77 |
+
results.show() # Show image with predicted masks
|
78 |
+
|
79 |
+
# To get the raw predictions (bounding boxes, masks, etc.)
|
80 |
+
for result in results:
|
81 |
+
print(result.boxes) # Bounding boxes
|
82 |
+
print(result.masks) # Segmentation masks
|
83 |
+
```
|
84 |
+
|
85 |
+
### Usage with the HTRflow package
|
86 |
+
|
87 |
+
See the model card for [Swedish Lion Libre](https://huggingface.co/Riksarkivet/trocr-base-handwritten-hist-swe-2)
|
88 |
+
for example usage with the [HTRflow package](https://github.com/AI-Riksarkivet/htrflow), or refer to the documentation for
|
89 |
+
[HTRflow](https://github.com/AI-Riksarkivet/htrflow)
|
90 |
+
|
91 |
+
## Training Details
|
92 |
+
|
93 |
+
### Training Data
|
94 |
+
|
95 |
+
[Trolldomskommissionen](https://huggingface.co/datasets/Riksarkivet/trolldomskommissionen_seg)
|
96 |
+
[Svea Hovrätt](https://huggingface.co/datasets/Riksarkivet/svea_hovratt_seg)
|
97 |
+
[Krigshovrättens domböcker](https://huggingface.co/datasets/Riksarkivet/krigshovrattens_dombocker_seg)
|
98 |
+
[Jönköpings rådhusrätt och magistrat](https://huggingface.co/datasets/Riksarkivet/jonkopings_radhusratts_och_magistrat_seg)
|
99 |
+
[Göta hovrätt](https://huggingface.co/datasets/Riksarkivet/gota_hovratt_seg)
|
100 |
+
[Frihetstidens utskottshandlingar](https://huggingface.co/datasets/Riksarkivet/frihetstidens_utskottshandlingar_seg)
|
101 |
+
[Bergskollegium relationer och skrivelser](https://huggingface.co/datasets/Riksarkivet/bergskollegium_relationer_och_skrivelser_seg)
|
102 |
+
[Bergskollegium advokatfiskalkontoret](https://huggingface.co/datasets/Riksarkivet/bergskollegium_advokatfiskalskontoret_seg)
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
### Training Procedure
|
107 |
+
|
108 |
+
|
109 |
+
#### Training Hyperparameters
|
110 |
+
|
111 |
+
See [training config](https://huggingface.co/Riksarkivet/yolov9-regions-1/blob/main/args.yaml) at model repo
|
112 |
+
|
113 |
+
|
114 |
+
## Evaluation
|
115 |
+
|
116 |
+
See [training results](https://huggingface.co/Riksarkivet/yolov9-regions-1/blob/main/results.csv)
|
117 |
+
|
118 |
+
|
119 |
+
#### Metrics
|
120 |
+
|
121 |
+
Standard metrics for instance segmentation. Note that evaluation of segmentation as part of an HTR-pipeline should be measured by what effect it
|
122 |
+
has on the following HTR, that is, CER and WER. For implementation and evaluation of entire HTR-pipelines, please check out [HTRflow](https://github.com/AI-Riksarkivet/htrflow),
|
123 |
+
the Swedish National Archive's open-source package for HTR and OCR projects.
|
124 |
+
|
125 |
+
|
126 |
+
### Model Architecture and Objective
|
127 |
+
|
128 |
+
yolov9
|
129 |
+
|
130 |
+
#### Software
|
131 |
+
|
132 |
+
[Ultralytics](https://github.com/ultralytics)
|
133 |
+
|
134 |
+
## Citation [optional]
|
135 |
+
|
136 |
+
[YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information](https://arxiv.org/abs/2402.13616)
|