This project provides two machine learning capabilities:
- Image Classification: Classify entire images into categories (fireballs, meteors, no_fireballs, etc.)
- Object Detection: Detect and localize objects within images using Faster R-CNN with bounding boxes
Train a Faster R-CNN model to detect and localize objects in images. Perfect for identifying multiple objects in a single image with precise bounding boxes.
Quick Start:
- See QUICKSTART_OBJECT_DETECTION.md for a 5-minute guide
- See OBJECT_DETECTION_README.md for complete documentation
Features:
- Faster R-CNN with ResNet50 backbone
- Train from scratch on custom datasets
- YOLO format annotation support (via image-classification app)
- Comprehensive metrics: mAP, IoU, Precision, Recall
- Model export to ONNX and TorchScript
This project uses a convolutional neural network (CNN) to classify images of the night sky into categories.
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
-
For common python libs
pip install -r requirements.txt
-
For systems with a compatible NVIDIA GPU:
pip install -r torch_requirements.txt
-
For systems with CPU only:
pip install -r torch_requirements_cpu.txt
-
-
Train the model:
Place your training data in a directory (e.g.,
training_data) with subdirectories for each class (e.g.,fireballs,meteors,no_fireballs,lightnings). Then run the training script:python -m src.train training_data OR python -m src.train_resnet18 training_data
Set model name in config.py.
CLASSES = ['fireballs', 'meteors', 'no_fireballs', 'lightnings'] CLASSES_SIZE = len(CLASSES) MODEL_PATH = 'night_sky_model_v11.pth' # used for main and watcher scripts TRAIN_MODEL_PATH = 'night_sky_model_v11.pth' # used to saved model file by train.py script RESNET18_MODEL_PATH = 'resnet18_trained_v1.pth' # used for main and watcher scripts RESNET18_TRAIN_MODEL_PATH = 'resnet18_trained_v1.pth' # used to saved model file by train.py script NUM_EPOCHS = 60 BATCH_SIZE = 8 LEARNING_RATE = 0.001 -
Classify a directory of images (one-time):
python -m src.main /path/to/your/images
-
Run the automatic watcher service:
To monitor a folder for new images and classify them automatically, run the watcher script. This will also send Telegram notifications for detected fireballs.
Before you start: You must edit the
src/watcher.pyfile and replace the placeholder values forTELEGRAM_BOT_TOKENandTELEGRAM_CHAT_IDwith your own credentials.python -m src.watcher /path/to/your/source_folder
This project can be packaged into a single executable file using PyInstaller.
-
Install PyInstaller:
pip install pyinstaller
-
Build the executable:
The entry point for the executable is
run.py. To build the watcher service, you will need to modifyrun.pyto callwatcher.main()instead ofmain.main().pyinstaller --name classify_sky_watcher --onefile --add-data "night_sky_model.pth:." run.py
=======
docker-compose build
docker-compose up
Basic data flow diagram:
flowchart
A[Cams]-->B[Dropbox]
B[DropBox] <-->|files auto sync| C(Local Machine Linux)
C --> D{Manual Python script running
python -m src. ...}
D --> E[Watcher]
D --> F[Classify images]
D --> G[Train model]
G <--> I@{ shape: docs, label: "Dataset" }