π― Hit Detector Model
This PyTorch-based CNN detects holes on boards or paper using a sliding window approach. It was trained on image patches of size 24Γ24. The model scans larger images with this patch size to detect regions of interest.
Holes or defects must approximately fit within a 20Γ20 region to be accurately detected.
π€ Model Card on Hugging Face.
π Live Demo
Try the model here: Hit Detector Gradio Demo
π₯ Model Inputs & Outputs
- Input: RGB or grayscale image (PIL.Image)
- Output: Annotated PIL.Image with red (or specified color) squares highlighting detected holes
π Quick Start
π§ Inference in Python
from PIL import Image
from pipeline import HitDetectorPipeline
pipe = HitDetectorPipeline("model.pt")
img = Image.open("input.png")
result = pipe(img)
result.save("output.png")
print("β
Output saved to output.png")
π¦ Installation
pip install -r requirements.txt
π§ͺ Testing in Docker
To test the model or pipeline scripts inside a clean container:
cd <project folder>
docker run -it --rm -p 7860:7860 -v $PWD:/appx:rw romanenco/python-tool-chain /bin/bash
cd /appx
pip install -r requirements.txt
python test_pipeline.py
You should see output.png generated as a result.
π Run Gradio UI
pip install gradio
python app.py
Open http://127.0.0.1:7860 to test the interactive web UI.
π Retrain or Fine-Tune
To retrain the model on your own dataset, use the full pipeline and tools from the main training repo, which includes:
- π Tools to extract training patches from full images
- π§ Training script
- π Inference script
π License
MIT
