Kosmos-2.5 is an innovative multimodal literate model created for reading and interpreting text within images. With its ability to perform transcription and structured text outputs, this model becomes an essential tool for anyone working with text-rich visuals. In this article, we will guide you through the steps to use Kosmos-2.5 effectively for different tasks.
Understanding Kosmos-2.5
Kosmos-2.5 operates like a well-trained librarian organizing a vast collection of books (text) within a library (image). Each book not only needs to be identified but also positioned correctly on its shelf/space to ensure easy access. The model tackles two core tasks:
- Generating Spatially-Aware Text Blocks: Each piece of text is mapped to its precise location in the image.
- Producing Structured Text Output: This formats the extracted text into a markdown style.
Executing Tasks with Kosmos-2.5
Kosmos-2.5 can be run using the provided Python scripts for different tasks. Below are the instructions for both the Markdown Task and the OCR Task:
Markdown Task
To extract and format text into markdown from an image, run the following command:
python md.py
This will generate a text output in markdown format, which includes items like:
- **1 [REG] BLACK SAKURA** 45,455
- **1 COOKIE DOH SAUCES** 0
- **1 NATA DE COCO** 0
- **Sub Total** 45,455
- **PB1 (10%)** 4,545
- **Rounding** 0
- **Total** **50,000**
OCR Task
For Optical Character Recognition (OCR) to extract raw text from images, you can use:
python ocr.py
The output will consist of numerical and text data such as:
55,595,71,595,71,629,55,629,182,...
- **Sub Total** 45,455
- **Total** 50,000
Troubleshooting and Tips
While working with Kosmos-2.5, you may encounter some issues that could hinder your experience. Here are some common troubleshooting ideas:
- Model Hallucination: Since Kosmos-2.5 is a generative model, it might produce information that doesn’t accurately represent what’s in the image. Cross-check the outputs with the original image for accuracy.
- File Format Issues: Ensure that the images used are in compatible formats supported by the model, such as PNG or JPEG.
- Dependencies and Setup: Make sure all required libraries mentioned in the documentation are installed and properly configured in your environment.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
Kosmos-2.5 is a powerful tool for anyone engaging with text-intensive images, from researchers to developers. With its dual capabilities for text generation and recognition, it simplifies workflows and enhances productivity.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

