Object detection
Project description
objectscope
ObjectScope is an extension of Detectron2 that streamlines model training and evaluation by adapting to the structure of your data and the workflows you rely on most. It offers high-level abstractions and utilities that automate key steps—such as dataset registration, anchor box refinement, model optimization, and quantization— out of the box all accessible through a single command.
Installation
To install and run objectscope successfully, you need to have Detectron2 installed. Incase you are using a gpu enabled device, then install objectscope with the appropriate CUDA version of PyTorch.
Install Detectron2
pip install git+https://github.com/facebookresearch/detectron2.git
Install objectscope with CUDA-enabled Pytorch
pip install objectscope --index-url https://pypi.org/simple --extra-index-url https://download.pytorch.org/whl/cu118
Usage
Objectscope can run from the terminal, Python script or Jupyter notebook.
Train model in python file / Jupyter notebook
from objectscope.trainer import TrainSession
trainer = TrainSession(train_img_dir="TRAIN_IMG_DIR",
train_coco_json_file="TRAIN_COCO_JSON_FILE",
test_img_dir="TEST_IMG_DIR",
test_coco_json_file="TEST_COCO_JSON_FILE",
config_file_url="CONFIG_FILE_URL",
num_classes="NUM_CLASSES",
train_data_name="train_data_name",
test_data_name="test_data_name",
train_metadata={},
test_metadata={},
output_dir="OUTPUT_DIR",
device="cuda,
num_workers=4,
imgs_per_batch=8,
base_lr=0.0001,
max_iter=5,
checkpoint_period=1,
)
trainer.run()
Train model using Terminal command
ObjectScope supports training, evaluation, optimization, ONNX export, and TensorBoard visualization—all from a single CLI command.
You can pass parameters via:
- Command-line arguments
- Environment variables
- A .env file
Command-line arguments take precedence when duplicates exist.
Example of training model from the terminal is as follows:
objectscope --train_img_dir "train"\
--test_img_dir "test" \
--output_dir "output_dir" \
--train_coco_json_file "train_annotations.coco.json" \
--test_coco_json_file "test_annotations.coco.json" \
--max_iter 5 --num_classes 15 --checkpoint_period 1 --roi_heads_score_threshold 0.5 \
--imgs_per_batch 4 --num_workers 10 --config_file_url "COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml" \
--device "cuda" --base_lr 0.00005 \
--show_tensorboard --optimize_model
Example .env file
TRAIN_IMG_DIR="train_images"\
test_img_dir="test_images" \
OUTPUT_DIR="output_dir" \
TRAIN_COCO_JSON_FILE="train_annotations.coco.json" \
TEST_COCO_JSON_FILE="test_annotations.coco.json" \
MAX_ITER=100000
NUM_CLASSES=15
CHECKPOINT_PERIOD=100
ROI_HEADS_SCORE_THRESHOLD=0.5
IMGS_PER_BATCH=4
NUM_WORKERS=10
CONFIG_FILE_URL="COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"
DEVICE="cuda"
BASE_LR=0.00005
SHOW_TENSORBOARD=true
OPTIMIZE_MODEL=true
Contributing
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
objectscope was created by Agbleze. It is licensed under the terms of the MIT license.
Credits
objectscope was created with cookiecutter and the py-pkgs-cookiecutter template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file objectscope-1.16.9.tar.gz.
File metadata
- Download URL: objectscope-1.16.9.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23a7f69b82c44d00688e25fcc1dfa3e49d406e4b90dd330c45cac31e3b17acef
|
|
| MD5 |
0bdfa30b2b934a5ffe7adc7e04bfac9e
|
|
| BLAKE2b-256 |
86aab5d2ca31d4aba80c207cb2b8e8428bfaabfb7fb86bda3d2a939bba2fbb7b
|
File details
Details for the file objectscope-1.16.9-py3-none-any.whl.
File metadata
- Download URL: objectscope-1.16.9-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9197131cfbf1b4402d99074147b11143def0cf9f63a6e04c21429f2e55af79c6
|
|
| MD5 |
79e2b4bf30f3cdd8dfffc2561d3f9e1b
|
|
| BLAKE2b-256 |
52558a6bc7be5b49e90bf12bf3a1d952ec285b3000798ebcfcfdfad032a2abb3
|