Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

SensorImageGuard

Binary image classifier to detect whether an image contains a DIY sensor (sensor) or not (no_sensor).

Project Structure

SensorImageGuard/
├── train_sensor_model.py
├── predict_sensor.py
├── requirements.txt
├── .gitignore
└── img/
    ├── img_sensors/
    └── img_negatives/
        ├── hard/
        │   ├── selected/
        │   └── fetch_hard_negatives.py
        └── soft/
            ├── all/
            ├── selected/
            └── select_random_soft.py

Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Data

  • Positive class (sensor=1): img/img_sensors/
  • Negative class (no_sensor=0):
    • img/img_negatives/hard/selected/
    • img/img_negatives/soft/selected/

Supported formats: .jpg, .jpeg, .png, .bmp, .webp, .tif, .tiff

Train

source .venv/bin/activate
python train_sensor_model.py \
  --sensor-dir img/img_sensors \
  --negative-dirs img/img_negatives/hard/selected img/img_negatives/soft/selected \
  --output model.h5

By default, training uses:

  • --val-split 0.2
  • --test-split 0.1

After training, the script prints:

  • best validation AUC (Best val_auc)
  • final test metrics:
    • loss
    • accuracy
    • auc
    • precision
    • recall

Predict

source .venv/bin/activate
python predict_sensor.py path/to/image.jpg --model model.h5 --image-size 128

Output:

  • label: sensor or label: no_sensor
  • sensor_probability: <float>

Notes

  • The model output layer is sensor_probability (sigmoid).
  • sensor_probability >= 0.5 maps to label sensor.
  • .h5 is used intentionally in this project.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages