prithivMLmods commited on
Commit
7a5ceca
·
verified ·
1 Parent(s): 41f5ff8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md CHANGED
@@ -11,3 +11,94 @@ tags:
11
  - text-generation-inference
12
  ---
13
  ![xvzxfv.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/2MNYn7ZsVkqX9lGVkJV47.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  - text-generation-inference
12
  ---
13
  ![xvzxfv.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/2MNYn7ZsVkqX9lGVkJV47.png)
14
+ # **Tokenized-OCR**
15
+
16
+ **Tokenized-OCR** is an advanced OCR-based text extraction tool optimized for generating structured, tokenized outputs. Built upon a powerful vision-language architecture with enhanced OCR and multilingual support, Tokenized-OCR accurately extracts text from images and returns it as a comma-separated sequence.
17
+
18
+ #### Key Enhancements:
19
+
20
+ * **Advanced OCR Engine**: Fine-tuned on extensive datasets, Tokenized-OCR ensures precise text recognition and tokenization.
21
+ * **Optimized for Tokenized Output**: Produces structured comma-separated text, making it ideal for downstream NLP tasks, automation pipelines, and database integrations.
22
+ * **Enhanced Multilingual OCR**: Supports text extraction in multiple languages, including English, Chinese, Japanese, Korean, Arabic, and more.
23
+ * **Multimodal Processing**: Seamlessly processes both image and text inputs, providing structured tokenized outputs.
24
+ * **Secure and Optimized Model Weights**: Employs safetensors for efficient and secure model loading.
25
+
26
+ ### How to Use
27
+
28
+ ```python
29
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
30
+ from qwen_vl_utils import process_vision_info
31
+
32
+ # Load the Tokenized-OCR model with optimized parameters
33
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
34
+ "prithivMLmods/Tokenized-OCR", torch_dtype="auto", device_map="auto"
35
+ )
36
+
37
+ # Recommended acceleration for performance optimization:
38
+ # model = Qwen2VLForConditionalGeneration.from_pretrained(
39
+ # "prithivMLmods/Tokenized-OCR",
40
+ # torch_dtype=torch.bfloat16,
41
+ # attn_implementation="flash_attention_2",
42
+ # device_map="auto",
43
+ # )
44
+
45
+ # Load the default processor for Tokenized-OCR
46
+ processor = AutoProcessor.from_pretrained("prithivMLmods/Tokenized-OCR")
47
+
48
+ # Define the input messages with both an image and a text prompt
49
+ messages = [
50
+ {
51
+ "role": "user",
52
+ "content": [
53
+ {
54
+ "type": "image",
55
+ "image": "https://flux-generated.com/sample_image.jpeg",
56
+ },
57
+ {"type": "text", "text": "Extract and return the tokenized OCR text from the image, ensuring each word is accurately recognized and separated by commas."},
58
+ ],
59
+ }
60
+ ]
61
+
62
+ # Prepare the input for inference
63
+ text = processor.apply_chat_template(
64
+ messages, tokenize=False, add_generation_prompt=True
65
+ )
66
+ image_inputs, video_inputs = process_vision_info(messages)
67
+ inputs = processor(
68
+ text=[text],
69
+ images=image_inputs,
70
+ videos=video_inputs,
71
+ padding=True,
72
+ return_tensors="pt",
73
+ )
74
+ inputs = inputs.to("cuda")
75
+
76
+ # Generate the output
77
+ generated_ids = model.generate(**inputs, max_new_tokens=256)
78
+ generated_ids_trimmed = [
79
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
80
+ ]
81
+ output_text = processor.batch_decode(
82
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
83
+ )
84
+ print(output_text)
85
+ ```
86
+
87
+ ### **Key Features**
88
+
89
+ 1. **High-Accuracy OCR Processing**
90
+ - Extracts and tokenizes text from images with exceptional precision.
91
+
92
+ 2. **Multilingual Text Recognition**
93
+ - Supports multiple languages, ensuring comprehensive OCR capabilities.
94
+
95
+ 3. **Comma-Separated Tokenized Output**
96
+ - Generates structured text for seamless NLP and data processing tasks.
97
+
98
+ 4. **Efficient Image & Text Processing**
99
+ - Handles both visual and textual inputs, ensuring accurate OCR-based extraction.
100
+
101
+ 5. **Optimized for Secure Deployment**
102
+ - Uses safetensors for enhanced security and model efficiency.
103
+
104
+ **Tokenized-OCR** revolutionizes text extraction from images, providing tokenized outputs that are easy to integrate into automated workflows, search engines, and language processing applications.