Skip to content

A Mask-RCNN model to detect the cigarettes in images and videos, extract masks and apply blur on

Notifications You must be signed in to change notification settings

Paradiddle131/Cigarette-Detecting-and-Blurring-with-Mask-RCNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Cigarette Detecting and Blurring Using Mask RCNN

This is an image segmentation project which detects and extracts the masks of cigarette instances in images using Mask R-CNN. The Mask R-CNN model generates bounding boxes and segmentation masks for each instance of an object in the image as the paper suggests.

Data

There are 731 unlabeled images of cigarettes scraped only from google images and 193 of them are labeled pixel-by-pixel. Further scraping will be done from stock websites.

Since the dataset is stored in my personal Google Drive account and the size of the dataset is larger than 100MB, I had to use a script in this reposityory of the user @circulosmeos which directly downloads big files from Google Drive sharing links.

To access the unlabeled images:

image

Download the gdown.pl script

wget -O gdown.pl "https://drive.google.com/uc?export=download&id=1gc-D4ydSBY7jqhlM-Oq2xca5oJx9217B"

Permit the user to run the script

chmod +x ./gdown.pl 

Download the data using the script

./gdown.pl 'https://drive.google.com/file/d/1-6QvZMUB13r-bN1eoiF3qlEplS_4imiK/view?usp=sharing' 'data-cigar-731.zip'

Unzip it

unzip ./data-cigar-731.zip -d /path/to/extract

To access the processed and labeled images:

image

./gdown.pl 'https://drive.google.com/file/d/1nHKQMUbhNBAyn307K5jEJmX2PBK7rlfz/view?usp=sharing' 'cigarette.zip'

Data Preprocessing

Because the dimensions of the images must be 1024x1024 before using Mask-RCNN model;

  • images smaller than the target size got expanded using np.pad() function of Numpy module image

  • images larger than the tarhet size got resized using resize() function of OpenCV module image

Training

You need to clone the Mask-RCNN GitHub Repository and configure the config files/codes according to your workspace and data. Instructions are given in the repository.

Results

Despite having a very shallow dataset, using transfer learning leads the model having some baseline results.

image image

Since the model has been trained with only ~200 images, it easily gives false results in some cases.

image

About

A Mask-RCNN model to detect the cigarettes in images and videos, extract masks and apply blur on

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published