https://github.com/addy999/omniparser-api
Self-hosted version of Microsoft's OmniParser Image-to-text model
https://github.com/addy999/omniparser-api
ai api fastapi flyio img2text llm python rest self-hosted
Last synced: 7 months ago
JSON representation
Self-hosted version of Microsoft's OmniParser Image-to-text model
- Host: GitHub
- URL: https://github.com/addy999/omniparser-api
- Owner: addy999
- Created: 2024-11-26T21:05:46.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-26T21:41:01.000Z (10 months ago)
- Last Synced: 2025-01-25T20:14:19.225Z (8 months ago)
- Topics: ai, api, fastapi, flyio, img2text, llm, python, rest, self-hosted
- Language: Python
- Homepage:
- Size: 950 KB
- Stars: 26
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OmniParser API
Self-hosted version of Microsoft's [OmniParser](https://huggingface.co/microsoft/OmniParser) Image-to-text model.
> OmniParser is a general screen parsing tool, which interprets/converts UI screenshot to structured format, to improve existing LLM based UI agent. Training Datasets include: 1) an interactable icon detection dataset, which was curated from popular web pages and automatically annotated to highlight clickable and actionable regions, and 2) an icon description dataset, designed to associate each UI element with its corresponding function.
## Why?
There's already a great HuggingFace gradio [app](https://huggingface.co/spaces/microsoft/OmniParser) for this model. It even offers an API. But
- Gradio is much slower than serving the model directly (like we do here)
- HF is rate-limited## How it works
If you look at the Dockerfile, we start off with the HF demo image to retrive all the weights and util functions. Then we add a simple FastAPI server (under main.py) to serve the model.
## Getting Started
### Requirements
- GPU
- 16 GB Ram (swap recommended)### Locally
1. Clone the repository
2. Build the docker image: `docker build -t omni-parser-app .`
3. Run the docker container: `docker run -p 7860:7860 omni-parser-app`### Self-hosted API
I suggest hosting on [fly.io](https://fly.io) because it's quick and simple to deploy with a CLI.
This repo is ready-made for deployment on fly.io (see fly.toml for configuration). Just run `fly launch` and follow the prompts.
## Docs
Visit `http://localhost:7860/docs` for the API documentation. There's only one route `/process_image` which returns
- The image with bounding boxes drawn on (in base64) format
- The parsed elements in a list with text descriptions
- The bounding box coordinates of the parsed elements## Examples
| Before Image | After Image |
| ---------------------------------- | ----------------------------- |
|  |  |## Related Projects
Check out [OneQuery](https://query-rho.vercel.app), an agent that browses the web and returns structured responses for any query, simple or complex. OneQuery is built using OmniParser to enhance its capabilities.