Views
No views yet

The Gliese-OCR-7B-Post2.0-final model is a refined and optimized version of Gliese-OCR-7B-Post1.0, built upon the Qwen2.5-VL architecture. It represents the final iteration in the Gliese-OCR series, offering enhanced efficiency, precision, and visualization capabilities for document OCR, visual analysis, and information extraction.Fine-tuned with extended document visualization data and OCR-focused objectives, this model delivers superior accuracy across a wide range of document types, including scanned PDFs, handwritten pages, structured forms, and analytical reports.
1from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
5 "prithivMLmods/Gliese-OCR-7B-Post2.0-final", torch_dtype="auto", device_map="auto"
6)
7
8processor = AutoProcessor.from_pretrained("prithivMLmods/Gliese-OCR-7B-Post2.0-final")
9
10messages = [
11 {
12 "role": "user",
13 "content": [
14 {"type": "image", "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"},
15 {"type": "text", "text": "Describe the document structure and extract key text content."},
16 ],
17 }
18]
19
20text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21image_inputs, video_inputs = process_vision_info(messages)
22inputs = processor(
23 text=[text],
24 images=image_inputs,
25 videos=video_inputs,
26 padding=True,
27 return_tensors="pt",
28).to("cuda")
29
30generated_ids = model.generate(**inputs, max_new_tokens=256)
31generated_ids_trimmed = [out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]
32output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)
33print(output_text)