Skip to content

aysa-dev1/pytorch_object_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Detection with PyTorch (torchvision)

This is a minimal example that runs a pretrained Faster R-CNN (ResNet-50 FPN) on a local image and saves an annotated image with bounding boxes and labels.

Project structure

.
├── data/              # Place your input image(s) here
├── src/
│   ├── __init__.py
│   └── detect.py      # Main script
├── requirements.txt
├── README.md
└── venv/              # (optional) Virtual environment lives here

Setup

  1. Create a virtual environment (recommended)
  • Windows (PowerShell):
python -m venv venv
./venv/Scripts/Activate.ps1
  • macOS / Linux:
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt

Usage

  1. Put an image in the data/ folder, for example data/input.jpg.

  2. Run the detector:

python -m src.detect --image data/input.jpg --output data/output.jpg --score-thresh 0.6

Adjust appearance of boxes and labels:

  • Increase line width:
python -m src.detect --image data/input.jpg --output data/output.jpg --score-thresh 0.6 --line-width 10
  1. Check data/output.jpg for the annotated result. If no detections are above the threshold, the original image will be saved and you will see a console message stating so.

Customization

  • Change --score-thresh to control how many boxes are shown.
  • Use a different output path (e.g., --output data/dog_boxes.jpg).

Preview test output

Test preview of the output

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages