Skip to content

Add Microsoft KOSMOS-2.5 model support to VLM evaluation application#1

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-517a1183-8bdd-4f19-9caa-89e49298de7f
Draft

Add Microsoft KOSMOS-2.5 model support to VLM evaluation application#1
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-517a1183-8bdd-4f19-9caa-89e49298de7f

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 28, 2025

This PR adds support for Microsoft's KOSMOS-2.5 vision-language model to the VLM evaluation application, enabling users to test and compare this model alongside the existing options.

Changes Made

Model Integration

  • Added KOSMOS-2.5 to model choices: Updated MODEL_CHOICES dictionary to include "microsoft/kosmos-2.5": "main"
  • Added required imports: Imported Kosmos2ForConditionalGeneration and Kosmos2Processor from the transformers library
  • Implemented model loading logic: Added specific loading configuration for KOSMOS-2.5 in the load_model_and_processor() function with proper device mapping and authentication
  • Implemented text extraction logic: Added input processing for KOSMOS-2.5 in the extract_text_from_image() function with appropriate prompt formatting using the <grounding> tag format

Documentation Updates

  • Updated README.md: Added KOSMOS-2.5 to the list of supported models in the project documentation

Technical Implementation Details

The KOSMOS-2.5 integration follows the established patterns in the codebase:

# Model loading with proper device mapping and authentication
model = Kosmos2ForConditionalGeneration.from_pretrained(
    model_name,
    torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
    device_map="auto" if torch.cuda.is_available() else None,
    use_auth_token=api_token
)
processor = Kosmos2Processor.from_pretrained(model_name, use_auth_token=api_token)

# Proper prompt formatting for KOSMOS-2 models
formatted_prompt = f"<grounding>An image of {prompt}"
inputs = processor(text=formatted_prompt, images=image, return_tensors='pt').to(device)

UI Changes

The KOSMOS-2.5 model is now available in the model selection dropdown alongside all existing models:

KOSMOS-2.5 Integration

KOSMOS-2.5 Selected

Testing

  • ✅ Application imports successfully with new KOSMOS-2.5 support
  • ✅ Model appears correctly in the UI dropdown
  • ✅ Flask application runs without errors
  • ✅ Integration follows existing code patterns and conventions

The implementation is minimal and surgical, adding only the necessary code to support KOSMOS-2.5 without modifying existing functionality for other models.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: python -c import requests; print(requests.get(&#39;REDACTED&#39;).json()) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 28, 2025 20:58
Co-authored-by: pexus <1809523+pexus@users.noreply.github.com>
Co-authored-by: pexus <1809523+pexus@users.noreply.github.com>
Copilot AI changed the title [WIP] I want you to look at this repo, that was created for evaluating various Vision language models. I see there is a new mode out there on huggingface - KOSMOS 2.5 https://huggingface.co/models?search=microsoft/kosmos-2.5 - I want to integrate this mode s... Add Microsoft KOSMOS-2.5 model support to VLM evaluation application Aug 28, 2025
Copilot AI requested a review from pexus August 28, 2025 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants