Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,127 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags: []
|
4 |
---
|
5 |
|
6 |
-
# Model Card for Model
|
7 |
|
8 |
-
|
9 |
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
##
|
13 |
|
14 |
-
###
|
|
|
|
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Uses
|
37 |
-
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
|
84 |
### Training Procedure
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags: [OCR]
|
4 |
---
|
5 |
|
6 |
+
# Model Card for Model qwen-for-jawi-v1
|
7 |
|
8 |
+
## Model Description
|
9 |
|
10 |
+
This model is a fine-tuned version of [Qwen/Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct) specialized for Optical Character Recognition (OCR) of historical Malay texts written in Jawi script (Arabic script adapted for Malay language).
|
11 |
|
12 |
+
### Model Architecture
|
13 |
+
- **Base Model**: Qwen2-VL-2B-Instruct
|
14 |
+
- **Model Type**: Vision-Language Model
|
15 |
+
- **Parameters**: 2 billion
|
16 |
+
- **Language(s)**: Malay (Jawi script)
|
17 |
|
18 |
+
## Intended Use
|
19 |
|
20 |
+
### Primary Intended Uses
|
21 |
+
- OCR for historical Malay manuscripts written in Jawi script
|
22 |
+
- Digital preservation of Malay cultural heritage
|
23 |
+
- Enabling computational analysis of historical Malay texts
|
24 |
|
25 |
+
### Out-of-Scope Uses
|
26 |
+
- General Arabic text recognition
|
27 |
+
- Modern Malay text processing
|
28 |
+
- Real-time OCR applications
|
29 |
|
30 |
+
## Training Data
|
31 |
|
32 |
+
### Dataset Description
|
33 |
+
This was trained and evaluated using
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
### Training Procedure
|
36 |
+
- Hardware used: 1 x H100
|
37 |
+
- Training time: 6 hours
|
38 |
+
|
39 |
+
## Performance and Limitations
|
40 |
+
|
41 |
+
### Performance Metrics
|
42 |
+
- Character Error Rate (CER): 8.66
|
43 |
+
- Word Error Rate (WER): 25.50
|
44 |
+
|
45 |
+
### Comparison with Other Models
|
46 |
+
We compared this model with https://github.com/VikParuchuri/surya, which reports high accuracy reates for Arabic, but performs poorly oun our Jawi data:
|
47 |
+
- Character Error Rate (CER): 70.89%
|
48 |
+
- Word Error Rate (WER): 91.73%
|
49 |
+
|
50 |
+
## How to Use
|
51 |
+
|
52 |
+
```python
|
53 |
+
# Example code for loading and using the model
|
54 |
+
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
|
55 |
+
import torch
|
56 |
+
from qwen_vl_utils import process_vision_info
|
57 |
+
from PIL import Image
|
58 |
+
|
59 |
+
model_name = 'mevsg/qwen-for-jawi-v1'
|
60 |
+
|
61 |
+
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
62 |
+
model_name,
|
63 |
+
torch_dtype=torch.bfloat16, # Use the appropriate torch dtype if needed
|
64 |
+
device_map='auto' # Optional: automatically allocate model layers across devices
|
65 |
+
)
|
66 |
+
|
67 |
+
# Load the processor from Hugging Face Hub
|
68 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct")
|
69 |
+
|
70 |
+
# Add example usage code
|
71 |
+
image_path = 'path/to/image'
|
72 |
+
image = Image.open(image_path).convert('RGB')
|
73 |
+
|
74 |
+
messages = [
|
75 |
+
{
|
76 |
+
"role": "user",
|
77 |
+
"content": [
|
78 |
+
{
|
79 |
+
"type": "image",
|
80 |
+
"image": image,
|
81 |
+
},
|
82 |
+
{"type": "text", "text": "Convert this image to text"},
|
83 |
+
],
|
84 |
+
}
|
85 |
+
]
|
86 |
+
|
87 |
+
# Preparation for inference
|
88 |
+
text = processor.apply_chat_template(
|
89 |
+
messages, tokenize=False, add_generation_prompt=True
|
90 |
+
)
|
91 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
92 |
+
inputs = processor(
|
93 |
+
text=[text],
|
94 |
+
images=image_inputs,
|
95 |
+
videos=video_inputs,
|
96 |
+
padding=True,
|
97 |
+
return_tensors="pt",
|
98 |
+
)
|
99 |
+
inputs = inputs.to("cuda")
|
100 |
+
|
101 |
+
# Inference: Generation of the output
|
102 |
+
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
103 |
+
generated_ids_trimmed = [
|
104 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
105 |
+
]
|
106 |
+
output_text = processor.batch_decode(
|
107 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
108 |
+
)
|
109 |
+
|
110 |
+
print(output_text)
|
111 |
+
```
|
112 |
+
|
113 |
+
## Citation
|
114 |
+
|
115 |
+
```bibtex
|
116 |
+
@misc{qwen-for-jawi-v1,
|
117 |
+
title = {Qwen for Jawi v1: a model for Jawi OCR},
|
118 |
+
author = {[Miguel Escobar Varela]},
|
119 |
+
year = {2024},
|
120 |
+
publisher = {HuggingFace},
|
121 |
+
url = {[https://huggingface.co/mevsg/qwen-for-Jawi-v1]},
|
122 |
+
note = {Model created at National University of Singapore }
|
123 |
+
}
|
124 |
+
```
|
125 |
+
|
126 |
+
## Acknowledgements
|
127 |
+
Special thanks to [William Mattingly](https://huggingface.co/wjbmattingly), whose finetuning script served as the base for our finetuning approach: https://github.com/wjbmattingly/qwen2-vl-finetune-huggingface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|