How aniketshinde8483/yolov8_streamlit_safety-detection works
Project type and purpose
• This is a single‐service, full-stack (monolithic) Streamlit application for YOLOv8‐based object detection.
• Purpose: Load a pre-trained YOLOv8 model (.pt file), accept image/video/webcam streams, perform inference, and render/display the annotated results in the browser (and optionally save to disk).
File structure
• Top-level files:
– app.py: Streamlit entrypoint (defines UI layout, handles user input, orchestrates model inference).
– settings.py: Configuration constants (paths, parameters such as confidence thresholds, default camera settings).
– best_150.pt (weights): The YOLOv8 model.
– requirements.txt / packages.txt: Python dependencies.
– outputs/: Directory where processed videos/images are saved.
– test_img_video/: Example media assets for manual testing.
– .devcontainer/: Docker/VSCode-DevContainer configuration for reproducible development environment.
README for additional insights
• Describes three use cases: image, video, live webcam object detection.
• Instructs to place model in weights/best.pt (in practice your repo uses best_150.pt).
• Entrypoint is streamlit run app.py.
Main components and relationships
a. Streamlit UI Layer (app.py)
– User selects input type (upload image, upload video, or webcam).
– UI widgets trigger controller logic.
b. Controller / Orchestration (app.py & settings.py)
– Reads settings, dispatches to the appropriate pipeline: image, video, or live.
c. Inference Engine
– Model Loader (loads best_150.pt via Ultralytics YOLOv8 API).
– Preprocessing Module (in helper.py: resizing, normalization).
– Inference Module (runs model.predict).
d. Storage & Artifacts
– Input Sources: Uploaded files or webcam stream.
– Output Sink: Annotated frames written to outputs/ (images or video).
– Temporary in-memory buffers for streaming.
e. Development Infrastructure
– .devcontainer (Dockerfile or devcontainer.json) for environment setup.
– requirements.txt for pip environment.
Architectural patterns and tech stack
• Pattern: Simple MVC-like separation
– View = Streamlit front end
– Controller = Main app logic in app.py
– Model = YOLOv8 model + helper functions
• Tech / Libraries:
– Python 3.x, Streamlit, Ultralytics YOLOv8, OpenCV or PIL for image/video I/O, ffmpeg (if video encoding), Docker (devcontainer).