How sefaburakokcu/autodetectify works
Project Type and Purpose
• Type: A full-stack, single‐page web app (no separate HTTP server/process) built on Streamlit.
• Purpose:
• Compare multiple zero‐shot object detection prompts side by side on user-uploaded images.
• Auto-label images with a chosen prompt and export labels in YOLOv5, YOLOv8, or COCO formats.
File Structure
• Top level:
• assets/ (static UI images)
• inputs/ (user or demo images)
• requirements.txt (dependencies: Streamlit, transformers, streamlit-image-comparison, etc.)
• Core ML code:
• autodetectify/models/zero_shot_detection/models.py → implements prompt handling & inference using HuggingFace transformers.
• UI code:
• ui/🤗_Home.py → entry point (Streamlit “Home” page)
• ui/pages/1_👀_Compare_Prompts.py → “Prompt Comparison” page
• ui/pages/2_📥_Autolabel_Images.py → “Auto-Label & Export” page
• ui/ui_utils.py → shared helpers (file uploaders, progress bars, export utilities)
Key README Insights
• Two main user flows: Prompt Comparison and Auto-Label + Export
• Supports up to 50 images or ZIP uploads
• Exports in multiple dataset formats
• Relies on streamlit-image-comparison for visual diff, HuggingFace transformers for zero-shot detection
Main Components & Their Relationships
A. User Interface Layer (Streamlit)
• HomePage Component
• ComparePromptsPage Component
• AutolabelPage Component
• UIUtils Module
B. Application Logic Layer
• InputHandler
– Receives image uploads (single/join ZIP)
– Saves into inputs/ folder (in-memory or temp)
• PromptManager
– Accepts user prompts (strings)
– Passes them to the inference engine
• InferenceEngine (ZeroShotDetector)
– Loads model from autodetectify/models/...
– Calls HuggingFace transformer pipeline
• ComparisonService
– Takes two or more inference results
– Uses streamlit-image-comparison widget for side-by-side display
• AutoLabelService
– Processes batch inference
– Applies chosen prompt across all images
• ExportService
– Converts results into YOLOv5, YOLOv8, COCO formats
– Packages into a downloadable ZIP
C. Data Layer
• Raw Images Store (inputs/ or in-memory stream)
• Processed Results (in-memory objects → visual display)
• Exported Dataset Files (written to disk/ZIP)
D. External Dependencies & Services
• HuggingFace Transformers (zero-shot models)
• streamlit-image-comparison widget
• Local File System (for assets, inputs, exports)
Architectural Patterns & Design Principles
• Modular separation of concerns: UI vs business logic vs data handling
• Stateless request handling: each user action triggers a fresh Streamlit “run”
• Single process (Streamlit) but logically layered
• Reusable utilities (ui_utils, ExportService) for consistent behavior
1. User & Browser
2. Streamlit UI Layer
3. Application Logic Layer
4. Data & External Services Layer
• Use rectangles for modules (e.g., ComparePromptsPage)
• User → UI (uploads images, types prompts)
• UI → InputHandler → Raw Images Store
• UI → InferenceEngine → HuggingFace → InferenceEngine → UI
• UI → ComparisonService → Display
• AutolabelPage → AutoLabelService → ExportService → Disk/ZIP → UI (download link)