ন্যানোনেটস-অর্ক-এস একটি শক্তিশালী, অত্যাধুনিক চিত্র-থেকে-মার্কডাউন ওসিআর মডেল যা traditional তিহ্যবাহী পাঠ্য উত্তোলনের চেয়ে অনেক বেশি। এটি ডকুমেন্টগুলিকে বুদ্ধিমান বিষয়বস্তু স্বীকৃতি এবং শব্দার্থক ট্যাগিংয়ের সাথে কাঠামোগত মার্কডাউনে রূপান্তরিত করে, এটি বৃহত ভাষার মডেলগুলি (এলএলএম) দ্বারা ডাউন স্ট্রিম প্রসেসিংয়ের জন্য আদর্শ করে তোলে।
ন্যানোনেটস-আওক্র-এস সহজেই জটিল নথিগুলি পরিচালনা করার জন্য ডিজাইন করা বৈশিষ্ট্যগুলি সহ প্যাক করা হয়েছে:
- ল্যাটেক্স সমীকরণ স্বীকৃতি: স্বয়ংক্রিয়ভাবে গাণিতিক সমীকরণ এবং সূত্রগুলি সঠিকভাবে ফর্ম্যাট করা ল্যাটেক্স সিনট্যাক্সে রূপান্তর করে। এটি ইনলাইন (এর মধ্যে পার্থক্য করে (
$...$
) এবং প্রদর্শন ($$...$$
) সমীকরণ। - বুদ্ধিমান চিত্রের বিবরণ: কাঠামোগত ব্যবহার করে নথির মধ্যে চিত্রগুলি বর্ণনা করে
<img>
ট্যাগস, এগুলি এলএলএম প্রসেসিংয়ের জন্য হজমযোগ্য করে তোলে। এটি লোগো, চার্ট, গ্রাফ এবং আরও অনেক কিছু সহ বিভিন্ন চিত্রের প্রকারগুলি বর্ণনা করতে পারে, তাদের সামগ্রী, শৈলী এবং প্রসঙ্গে বিশদ বিবরণ করে। - স্বাক্ষর সনাক্তকরণ এবং বিচ্ছিন্নতা: অন্যান্য পাঠ্য থেকে স্বাক্ষরগুলি সনাক্ত করে এবং বিচ্ছিন্ন করে, এগুলির মধ্যে তাদের আউটপুট করে
<signature>
ট্যাগ। আইনী এবং ব্যবসায়িক নথি প্রক্রিয়াকরণের জন্য এটি গুরুত্বপূর্ণ। - ওয়াটারমার্ক এক্সট্রাকশন: নথিগুলি থেকে ওয়াটারমার্ক পাঠ্য সনাক্ত করে এবং বের করে, এটি একটিতে রাখে
<watermark>
ট্যাগ। - স্মার্ট চেকবক্স হ্যান্ডলিং: ফর্ম চেকবক্স এবং রেডিও বোতামগুলিকে স্ট্যান্ডার্ডাইজড ইউনিকোড প্রতীকগুলিতে রূপান্তর করে (
☐
,☑
,☒
) ধারাবাহিক এবং নির্ভরযোগ্য প্রক্রিয়াজাতকরণের জন্য। - জটিল টেবিল নিষ্কাশন: ডকুমেন্টগুলি থেকে সঠিকভাবে জটিল টেবিলগুলি বের করে এবং সেগুলি মার্কডাউন এবং এইচটিএমএল টেবিল উভয় ফর্ম্যাটে রূপান্তর করে।
📢 সম্পূর্ণ ঘোষণা পড়ুন | 🤗 আলিঙ্গন ফেস স্পেস ডেমো
ব্যবহার
ট্রান্সফর্মার ব্যবহার করে
from PIL import Image
from transformers import AutoTokenizer, AutoProcessor, AutoModelForImageTextToText
model_path = "nanonets/Nanonets-OCR-s"
model = AutoModelForImageTextToText.from_pretrained(
model_path,
torch_dtype="auto",
device_map="auto",
attn_implementation="flash_attention_2"
)
model.eval()
tokenizer = AutoTokenizer.from_pretrained(model_path)
processor = AutoProcessor.from_pretrained(model_path)
def ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=4096):
prompt = """Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using ☐ and ☑ for check boxes."""
image = Image.open(image_path)
messages = (
"role": "system", "content": "You are a helpful assistant.",
"role": "user", "content": (
"type": "image", "image": f"file://image_path",
"type": "text", "text": prompt,
),
)
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=(text), images=(image), padding=True, return_tensors="pt")
inputs = inputs.to(model.device)
output_ids = model.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=False)
generated_ids = (output_ids(len(input_ids):) for input_ids, output_ids in zip(inputs.input_ids, output_ids))
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)
return output_text(0)
image_path = "/path/to/your/document.jpg"
result = ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=15000)
print(result)
ভিএলএলএম ব্যবহার করে
- ভিএলএলএম সার্ভার শুরু করুন।
vllm serve nanonets/Nanonets-OCR-s
- মডেল সঙ্গে ভবিষ্যদ্বাণী
from openai import OpenAI
import base64
client = OpenAI(api_key="123", base_url="http://localhost:8000/v1")
model = "nanonets/Nanonets-OCR-s"
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")
def ocr_page_with_nanonets_s(img_base64):
response = client.chat.completions.create(
model=model,
messages=(
"role": "user",
"content": (
"type": "image_url",
"image_url": "url": f"data:image/png;base64,img_base64",
,
"type": "text",
"text": "Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using ☐ and ☑ for check boxes.",
,
),
),
temperature=0.0,
max_tokens=15000
)
return response.choices(0).message.content
test_img_path = "/path/to/your/document.jpg"
img_base64 = encode_image(test_img_path)
print(ocr_page_with_nanonets_s(img_base64))
ডসেক্সট ব্যবহার করে
pip install docext
python -m docext.app.app --model_name hosted_vllm/nanonets/Nanonets-OCR-s
চেকআউট গিরুব আরও বিশদ জন্য।
বিবিটেক্স
@miscNanonets-OCR-S,
title=Nanonets-OCR-S: A model for transforming documents into structured markdown with intelligent content recognition and semantic tagging,
author=Souvik Mandal and Ashish Talewar and Paras Ahuja and Prathamesh Juvatkar,
year=2025,