{"id":37075679,"url":"https://github.com/datamarkin/mozo","last_synced_at":"2026-01-14T08:54:22.270Z","repository":{"id":318740417,"uuid":"1076316558","full_name":"datamarkin/mozo","owner":"datamarkin","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-24T00:28:12.000Z","size":809,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-01T11:42:20.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datamarkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-14T17:30:59.000Z","updated_at":"2025-11-24T00:28:15.000Z","dependencies_parsed_at":"2025-11-11T18:02:52.005Z","dependency_job_id":null,"html_url":"https://github.com/datamarkin/mozo","commit_stats":null,"previous_names":["datamarkin/mozo"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/datamarkin/mozo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datamarkin%2Fmozo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datamarkin%2Fmozo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datamarkin%2Fmozo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datamarkin%2Fmozo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datamarkin","download_url":"https://codeload.github.com/datamarkin/mozo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datamarkin%2Fmozo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T08:54:21.529Z","updated_at":"2026-01-14T08:54:22.244Z","avatar_url":"https://github.com/datamarkin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mozo\n\nUniversal computer vision model server with automatic memory management and multi-framework support.\n\nMozo provides HTTP access to 35+ pre-configured models across 11 model families from Detectron2, HuggingFace Transformers, PaddleOCR, EasyOCR, and other frameworks. Models load on-demand and clean up automatically.\n\n## Quick Start\n\n```bash\npip install mozo\nmozo start\n```\n\nServer starts on `http://localhost:8000` with all models available via REST API.\n\n### Examples\n\nObject detection:\n```bash\ncurl -X POST \"http://localhost:8000/predict/detectron2/mask_rcnn_R_50_FPN_3x\" \\\n  -F \"file=@image.jpg\"\n```\n\nDepth estimation:\n```bash\ncurl -X POST \"http://localhost:8000/predict/depth_anything/small\" \\\n  -F \"file=@image.jpg\" --output depth.png\n```\n\nVision-language Q\u0026A:\n```bash\ncurl -X POST \"http://localhost:8000/predict/qwen2.5_vl/7b-instruct?prompt=What%20is%20in%20this%20image\" \\\n  -F \"file=@image.jpg\"\n```\n\nList available models:\n```bash\ncurl http://localhost:8000/models\n```\n\n## Features\n\n- **35+ Pre-configured Models** - 11 model families including Detectron2, HuggingFace Transformers, PaddleOCR, EasyOCR, Florence-2, BLIP VQA, and more\n- **Automatic Memory Management** - Lazy loading, usage tracking, automatic cleanup\n- **Multi-Framework Support** - Unified API across different ML frameworks\n- **PixelFlow Integration** - Detection models return unified format for filtering and annotation\n- **Thread-Safe** - Concurrent request handling with per-model locks\n- **Production Ready** - Multiple workers, configurable timeouts, health checks\n\n## Installation\n\n```bash\n# Basic installation\npip install mozo\n\n# Framework dependencies (install as needed)\npip install transformers torch torchvision\npip install 'git+https://github.com/facebookresearch/detectron2.git'\n```\n\n## Available Models\n\n### Detectron2 (17 variants)\nObject detection, instance segmentation, keypoint detection trained on COCO dataset.\n\nPopular variants:\n- `mask_rcnn_R_50_FPN_3x` - Instance segmentation\n- `faster_rcnn_R_50_FPN_3x` - Object detection\n- `faster_rcnn_X_101_32x8d_FPN_3x` - High-accuracy detection\n- `keypoint_rcnn_R_50_FPN_3x` - Keypoint detection\n- `retinanet_R_50_FPN_3x` - Single-stage detector\n\nOutput: JSON with bounding boxes, class names, confidence scores (80 COCO classes)\n\n### Depth Anything (3 variants)\nMonocular depth estimation.\n\n- `small` - Fastest, lowest memory\n- `base` - Balanced performance\n- `large` - Best accuracy\n\nOutput: PNG grayscale depth map\n\n### Qwen2.5-VL (1 variant)\nVision-language understanding for VQA, captioning, and image analysis.\n\n- `7b-instruct` - 7B parameter model (requires 16GB+ RAM)\n\nOutput: JSON with text response\n\n## Server\n\n```bash\n# Start with defaults (0.0.0.0:8000, auto-reload enabled)\nmozo start\n\n# Custom port\nmozo start --port 8080\n\n# Production mode with multiple workers\nmozo start --workers 4\n\n# Check version\nmozo version\n```\n\n## API Reference\n\n### Run Prediction\n```http\nPOST /predict/{family}/{variant}\nContent-Type: multipart/form-data\n```\n\nParameters:\n- `family` - Model family (e.g., `detectron2`, `depth_anything`, `qwen2.5_vl`)\n- `variant` - Model variant (e.g., `mask_rcnn_R_50_FPN_3x`, `small`, `7b-instruct`)\n- `file` - Image file\n- `prompt` - Text prompt (VLM models only)\n\n### Health Check\n```http\nGET /\n```\n\nReturns server status and loaded models.\n\n### List Models\n```http\nGET /models\n```\n\nReturns all available model families and variants.\n\n### List Loaded Models\n```http\nGET /models/loaded\n```\n\nReturns currently loaded models with usage information.\n\n### Get Model Info\n```http\nGET /models/{family}/{variant}/info\n```\n\nReturns detailed information about a specific model variant.\n\n### Unload Model\n```http\nPOST /models/{family}/{variant}/unload\n```\n\nManually unload a model to free memory.\n\n### Cleanup Inactive Models\n```http\nPOST /models/cleanup?inactive_seconds=600\n```\n\nUnload models inactive for specified duration (default: 600 seconds).\n\n## How It Works\n\n**Lazy Loading**\nModels load on first request, not at server startup. This keeps startup time instant regardless of available models.\n\n**Smart Caching**\nLoaded models stay in memory and are reused across requests. First request is slower (model download + load), subsequent requests are fast.\n\n**Usage Tracking**\nEach model access updates a timestamp. Models inactive for 10+ minutes are automatically unloaded.\n\n**Thread Safety**\nPer-model locks ensure only one thread loads a given model. Other threads wait and reuse the loaded instance.\n\nExample flow:\n```bash\n# Server starts instantly (no models loaded)\nmozo start\n\n# First request loads model\ncurl -X POST \"http://localhost:8000/predict/detectron2/faster_rcnn_R_50_FPN_3x\" -F \"file=@test.jpg\"\n# Output: [ModelManager] Loading model: detectron2/faster_rcnn_R_50_FPN_3x...\n\n# Subsequent requests reuse loaded model\ncurl -X POST \"http://localhost:8000/predict/detectron2/faster_rcnn_R_50_FPN_3x\" -F \"file=@test2.jpg\"\n# Output: [ModelManager] Model already loaded, reusing existing instance.\n\n# After 10 minutes of inactivity, model auto-unloads\n# Output: [ModelManager] Cleanup: Unloaded 1 inactive model(s).\n```\n\n## Python SDK\n\nFor direct integration in Python applications:\n\n```python\nfrom mozo import ModelManager\nimport cv2\n\nmanager = ModelManager()\nmodel = manager.get_model('detectron2', 'mask_rcnn_R_50_FPN_3x')\n\nimage = cv2.imread('image.jpg')\ndetections = model.predict(image)\n\n# Filter results\nhigh_confidence = detections.filter_by_confidence(0.8)\n\n# Manual memory management\nmanager.unload_model('detectron2', 'mask_rcnn_R_50_FPN_3x')\nmanager.cleanup_inactive_models(inactive_seconds=300)\n```\n\n### PixelFlow Integration\n\nDetection models return PixelFlow Detections objects - a unified format across all ML frameworks:\n\n```python\n# Works the same for Detectron2, YOLO, or custom models\ndetections = model.predict(image)\n\n# Filter and annotate\nimport pixelflow as pf\nfiltered = detections.filter_by_confidence(0.8).filter_by_class_id([0, 2])\nannotated = pf.annotate.box(image, filtered)\nannotated = pf.annotate.label(annotated, filtered)\n\n# Export\njson_output = filtered.to_json()\n```\n\nLearn more: [PixelFlow](https://github.com/datamarkin/pixelflow)\n\n## Configuration\n\n### Environment Variables\n\n```bash\n# Enable MPS fallback for macOS (Apple Silicon)\nexport PYTORCH_ENABLE_MPS_FALLBACK=1\n\n# Configure HuggingFace cache location\nexport HF_HOME=~/.cache/huggingface\n```\n\n### Memory Management\n\nModels automatically unload after 10 minutes of inactivity. Adjust this:\n\n```bash\ncurl -X POST \"http://localhost:8000/models/cleanup?inactive_seconds=300\"\n```\n\nOr in Python:\n```python\nmanager.cleanup_inactive_models(inactive_seconds=300)\n```\n\n## Extending Mozo\n\nAdd new models in 3 steps:\n\n1. Create adapter in `mozo/adapters/your_model.py`\n2. Register in `mozo/registry.py`\n3. Use via HTTP or Python API\n\nSee [CLAUDE.md](CLAUDE.md) for detailed implementation guide.\n\n## Architecture\n\n```\nHTTP Request → FastAPI Server → ModelManager → ModelFactory → Adapter → Framework\n                                      ↓\n                               Thread-safe cache\n                               Usage tracking\n                               Auto cleanup\n```\n\nComponents:\n- **Server** - FastAPI REST API\n- **Manager** - Lifecycle management, caching, cleanup\n- **Factory** - Dynamic adapter instantiation\n- **Registry** - Central catalog of models\n- **Adapters** - Framework-specific implementations\n\n## Development\n\n```bash\n# Install in development mode\npip install -e .\n\n# Start server with auto-reload\nmozo start\n```\n\n## Documentation\n\n- [Repository](https://github.com/datamarkin/mozo)\n- [Issues](https://github.com/datamarkin/mozo/issues)\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatamarkin%2Fmozo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatamarkin%2Fmozo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatamarkin%2Fmozo/lists"}