How phamdangnguyen/yolov5_animals works
Project type and purpose
• This is a standalone computer‑vision application built on YOLOv5 for detecting 25 different animal classes in video streams or files.
• It includes two primary use cases:
• Inference: A desktop GUI app (Main.py + Screen.py/Screen.ui) for loading videos, running detection, displaying/saving results.
• Training: A Jupyter notebook (Train_model.ipynb) to train or fine‑tune the YOLOv5 model on 8,000 labeled images.
File structure
• Top‑level scripts:
• Main.py – application entry point (likely uses PyInstaller .spec to bundle).
• Screen.py + Screen.ui – GUI controller and Qt Designer form.
• Model resources:
• best_8_tieng.pt – the trained YOLOv5 weights.
• Data inputs:
• Labeled_Video.avi, Animals.mp4, Buom.mp4 – sample video inputs.
• Output/storage:
• Save_pic/ – folder where detected frames or snapshots are saved.
• Training artifacts:
• Train_model.ipynb – Jupyter notebook for training.
• Deployment:
• Main.spec – PyInstaller configuration to package the app.
Extract additional insights from README
• Confirms YOLOv5 usage for animal detection.
• Mentions training duration (~8 hours), dataset size (25 classes, 8k images).
Main components and how to represent them
a. Components
– User Interface Layer
• GUI (Screen.ui + Screen.py)
– Application Core
• Main.py (app bootstrap, ties UI and inference)
• Inference Engine (YOLOv5 model loader + frame processor)
– Data Layer
• Video Input (file system or camera)
• Save_pic directory (output snapshots)
• Model Storage (best_8_tieng.pt)
– Training Module (Jupyter notebook + dataset)
– External Dependencies
• PyTorch (model inference & training)
• OpenCV (video I/O, image processing)
• PyQt5 (GUI)
• PyInstaller (packaging)
b. Relationships & interactions
– The User interacts with the GUI -> GUI sends “start detection” command to Main.
– Main bootstraps the Inference Engine, loads best_8_tieng.pt via PyTorch.
– Inference Engine reads frames from Video Input via OpenCV, runs YOLOv5 detection.
– Detected frames are passed back to the GUI for display and saved to Save_pic.
– Separately, the Training Module (Train_model.ipynb) reads the same labeled dataset, uses PyTorch & YOLOv5 training scripts to produce best_8_tieng.pt.
– PyInstaller (Main.spec) consumes Main.py + dependencies and bundles them into a standalone executable.
c. Architectural patterns & design principles
– MVC‑like separation:
• View = Screen.ui
• Controller = Screen.py / Main.py
• Model = YOLOv5 weights + inference logic
– Modular separation of concerns: inference vs. training vs. packaging
– Data flow is unidirectional: Input → Processing → Output
d. Key technologies/frameworks
– YOLOv5 (PyTorch)
– PyQt5 (GUI)
– OpenCV (Video/Frame I/O)
– Jupyter / IPython for training
– PyInstaller for deployment