Spaces:
Running
Running
| """ | |
| Quick start example for OmniParser API | |
| """ | |
| import subprocess | |
| import sys | |
| import time | |
| import requests | |
| from pathlib import Path | |
| def main(): | |
| """Quick start guide""" | |
| print("\n" + "=" * 60) | |
| print("OmniParser-v2.0 QUICK START GUIDE") | |
| print("=" * 60 + "\n") | |
| print("This guide will help you get started with OmniParser API.\n") | |
| # Step 1: Virtual Environment | |
| print("STEP 1: Setup Virtual Environment") | |
| print("-" * 60) | |
| print("Windows:") | |
| print(" python -m venv venv") | |
| print(" venv\\Scripts\\activate.bat") | |
| print("\nLinux/macOS:") | |
| print(" python3 -m venv venv") | |
| print(" source venv/bin/activate\n") | |
| # Step 2: Install Dependencies | |
| print("STEP 2: Install Dependencies") | |
| print("-" * 60) | |
| print("Run: pip install -r requirements.txt") | |
| print("(This will take a few minutes)\n") | |
| # Step 3: Configuration | |
| print("STEP 3: Configuration") | |
| print("-" * 60) | |
| print("Copy .env.example to .env and edit if needed") | |
| print("Run: copy .env.example .env (Windows)") | |
| print(" or: cp .env.example .env (Linux/macOS)\n") | |
| # Step 4: Run Server | |
| print("STEP 4: Run the Server") | |
| print("-" * 60) | |
| print("Run: python main.py") | |
| print("Expected output: 'INFO: Uvicorn running on http://0.0.0.0:8000'\n") | |
| # Step 5: Test API | |
| print("STEP 5: Test the API") | |
| print("-" * 60) | |
| print("Option A - Interactive Docs:") | |
| print(" Open: http://localhost:8000/docs") | |
| print(" Click 'Try it out' on any endpoint\n") | |
| print("Option B - Python Script:") | |
| print(" python test_api.py\n") | |
| print("Option C - cURL:") | |
| print(" curl -X GET http://localhost:8000/health\n") | |
| # Next Steps | |
| print("NEXT STEPS:") | |
| print("-" * 60) | |
| print("1. Upload a screenshot: POST /parse") | |
| print("2. Extract UI elements with coordinates") | |
| print("3. Integrate with your application\n") | |
| print("For more information:") | |
| print("- See README.md for detailed documentation") | |
| print("- Visit: https://huggingface.co/microsoft/OmniParser-v2.0") | |
| print("- API Docs: http://localhost:8000/docs\n") | |
| print("=" * 60 + "\n") | |
| if __name__ == "__main__": | |
| main() | |