├── .gitignore ├── AWS-Marketplace.png ├── README.md ├── Using-PPE-Detector-Endpoint.ipynb ├── Using-Personal-Protection-Equipment-Detection-model.ipynb ├── data └── test_samples │ ├── demo_input │ ├── 102_31.pexels-photo-5834...jpg │ ├── 105_32.Welding_2.jpg...jpg │ ├── 108_87.13520761816095.jp...jpg │ ├── 114_59.construction-1717...jpg │ ├── 11_43.work-711708_960_7...jpg │ ├── 15_10.site-1536863_960_...jpg │ ├── 17_34.160728-F-VV898-05...jpg │ ├── 18_2.Man-Manufacturing-...jpg │ ├── 28_10.pexels-photo-2918...jpg │ ├── 31_17.BP_subsea_oil_rec...jpg │ ├── 50_31.WomanFactory1940s...jpg │ ├── 54_11.Welder_in_Egypt_(...jpg │ ├── 58_30.worker-work-build...jpg │ ├── 61_2.worker-on-construc...jpg │ ├── 79_32.site-1536859_960_...jpg │ └── README.md │ ├── demo_output_images │ ├── 102_31.pexels-photo-5834...jpg │ ├── 105_32.Welding_2.jpg...jpg │ ├── 108_87.13520761816095.jp...jpg │ ├── 114_59.construction-1717...jpg │ ├── 11_43.work-711708_960_7...jpg │ ├── 15_10.site-1536863_960_...jpg │ ├── 17_34.160728-F-VV898-05...jpg │ ├── 18_2.Man-Manufacturing-...jpg │ ├── 20_14.construction-1181...jpg │ ├── 28_10.pexels-photo-2918...jpg │ ├── 31_17.BP_subsea_oil_rec...jpg │ ├── 50_31.WomanFactory1940s...jpg │ ├── 54_11.Welder_in_Egypt_(...jpg │ ├── 58_30.worker-work-build...jpg │ ├── 61_2.worker-on-construc...jpg │ ├── 79_32.site-1536859_960_...jpg │ └── README.md │ └── demo_raw_output │ ├── 102_31.pexels-photo-5834...jpg.out │ ├── 105_32.Welding_2.jpg...jpg.out │ ├── 108_87.13520761816095.jp...jpg.out │ ├── 114_59.construction-1717...jpg.out │ ├── 11_43.work-711708_960_7...jpg.out │ ├── 15_10.site-1536863_960_...jpg.out │ ├── 17_34.160728-F-VV898-05...jpg.out │ ├── 18_2.Man-Manufacturing-...jpg.out │ ├── 28_10.pexels-photo-2918...jpg.out │ ├── 31_17.BP_subsea_oil_rec...jpg.out │ ├── 50_31.WomanFactory1940s...jpg.out │ ├── 54_11.Welder_in_Egypt_(...jpg.out │ ├── 58_30.worker-work-build...jpg.out │ ├── 61_2.worker-on-construc...jpg.out │ ├── 79_32.site-1536859_960_...jpg.out │ └── README.md └── utils.py /.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints/ 2 | __pycache__/ 3 | .vs/ 4 | .vscode/ 5 | -------------------------------------------------------------------------------- /AWS-Marketplace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/AWS-Marketplace.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PPE Detector for Worker Safety 2 | [The PPE Detector for Worker Safety](https://aws.amazon.com/marketplace/pp/prodview-6gvzwuebead3o) - is a real-time computer vision model for PPE non-compliance detection in the industrial setting. The solution detects seven object classes: Bare Head, Helmet, Ear Protection, Welding Mask, Bare Chest(NO Visibility Vest), High Visibility Vest, Person. 3 | 4 | [![AWS Marketplace](AWS-Marketplace.png)](https://aws.amazon.com/marketplace/pp/prodview-6gvzwuebead3o) 5 | 6 | ## Usage Information 7 | 8 | Using our model for real time prediction is as simple as this: 9 | 10 | ```python 11 | predictor = sagemaker.predictor.RealTimePredictor( 12 | ' your endpoint name ', 13 | sagemaker_session=sagemaker.Session(), 14 | content_type="image/jpeg" 15 | ) 16 | 17 | with open('data/sample_image.jpg', 'rb') as img: 18 | img_bytes = bytearray(img.read()) 19 | result = predictor.predict(img_bytes).decode("utf-8") 20 | ``` 21 | 22 | Also we've published two notebooks showing how to use our model: 23 | * [Using-PPE-Detector-Endpoint.ipynb](Using-PPE-Detector-Endpoint.ipynb) notebook shows how you can use Python API to perform inference on endpoint created from the model 24 | * [Using-Personal-Protection-Equipment-Detection-model.ipynb](Using-Personal-Protection-Equipment-Detection-model.ipynb) notebook shows how you can use Python API to run the full scenario: 25 | * deploy our model to create an endpoint 26 | * run Real Time inference on endpoint using local image 27 | * visualize and save the prediction on original image 28 | * run Batch Transform job to perfom the inference on your data stored in Amazon S3 bucket 29 | 30 | ## Input\output data examples 31 | 32 | * You can find sample input data in [demo_input](data/test_samples/demo_input) folder 33 | * [demo_output_images](data/test_samples/demo_output_images) folder contains images with detections predicted by the model and visualized using `utils.visualize_detection` method 34 | * [demo_raw_output](data/test_samples/demo_raw_output) folder contains raw output generated by our model using `Batch Transform` approach 35 | 36 | ## Sample detection results: 37 | 38 | ![PPE Detector output example](data/test_samples/demo_output_images/54_11.Welder_in_Egypt_%28...jpg?raw=true) 39 | 40 | ![PPE Detector output example](data/test_samples/demo_output_images/17_34.160728-F-VV898-05...jpg?raw=true) 41 | 42 | ![PPE Detector output example](data/test_samples/demo_output_images/79_32.site-1536859_960_...jpg?raw=true) 43 | 44 | ![PPE Detector output example](data/test_samples/demo_output_images/108_87.13520761816095.jp...jpg?raw=true) 45 | -------------------------------------------------------------------------------- /data/test_samples/demo_input/102_31.pexels-photo-5834...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/102_31.pexels-photo-5834...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/105_32.Welding_2.jpg...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/105_32.Welding_2.jpg...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/108_87.13520761816095.jp...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/108_87.13520761816095.jp...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/114_59.construction-1717...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/114_59.construction-1717...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/11_43.work-711708_960_7...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/11_43.work-711708_960_7...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/15_10.site-1536863_960_...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/15_10.site-1536863_960_...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/17_34.160728-F-VV898-05...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/17_34.160728-F-VV898-05...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/18_2.Man-Manufacturing-...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/18_2.Man-Manufacturing-...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/28_10.pexels-photo-2918...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/28_10.pexels-photo-2918...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/31_17.BP_subsea_oil_rec...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/31_17.BP_subsea_oil_rec...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/50_31.WomanFactory1940s...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/50_31.WomanFactory1940s...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/54_11.Welder_in_Egypt_(...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/54_11.Welder_in_Egypt_(...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/58_30.worker-work-build...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/58_30.worker-work-build...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/61_2.worker-on-construc...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/61_2.worker-on-construc...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/79_32.site-1536859_960_...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_input/79_32.site-1536859_960_...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_input/README.md: -------------------------------------------------------------------------------- 1 | ## Sample data input 2 | 3 | Sample PPE Detector input images -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/102_31.pexels-photo-5834...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/102_31.pexels-photo-5834...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/105_32.Welding_2.jpg...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/105_32.Welding_2.jpg...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/108_87.13520761816095.jp...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/108_87.13520761816095.jp...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/114_59.construction-1717...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/114_59.construction-1717...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/11_43.work-711708_960_7...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/11_43.work-711708_960_7...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/15_10.site-1536863_960_...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/15_10.site-1536863_960_...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/17_34.160728-F-VV898-05...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/17_34.160728-F-VV898-05...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/18_2.Man-Manufacturing-...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/18_2.Man-Manufacturing-...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/20_14.construction-1181...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/20_14.construction-1181...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/28_10.pexels-photo-2918...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/28_10.pexels-photo-2918...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/31_17.BP_subsea_oil_rec...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/31_17.BP_subsea_oil_rec...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/50_31.WomanFactory1940s...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/50_31.WomanFactory1940s...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/54_11.Welder_in_Egypt_(...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/54_11.Welder_in_Egypt_(...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/58_30.worker-work-build...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/58_30.worker-work-build...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/61_2.worker-on-construc...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/61_2.worker-on-construc...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/79_32.site-1536859_960_...jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VITechLab/PPE-Detector/6a176cd54c482e5ca071775765f6d0fe670c427e/data/test_samples/demo_output_images/79_32.site-1536859_960_...jpg -------------------------------------------------------------------------------- /data/test_samples/demo_output_images/README.md: -------------------------------------------------------------------------------- 1 | ## Output data examples 2 | 3 | This folder contains images with detections predicted by PPE Detector model and visualized using `utils.visualize_detection` method -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/102_31.pexels-photo-5834...jpg.out: -------------------------------------------------------------------------------- 1 | [[1230.0, 133.0, 1555.0, 390.0, 0.8730621337890625, 0.9998264908790588, 1.0], [1256.0, 411.0, 1728.0, 1042.0, 0.6474020481109619, 0.9923801422119141, 4.0], [1237.0, 218.0, 1737.0, 1202.0, 0.5285742878913879, 0.574576735496521, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/105_32.Welding_2.jpg...jpg.out: -------------------------------------------------------------------------------- 1 | [[1569.0, 211.0, 1917.0, 548.0, 0.7079853415489197, 0.9990969896316528, 0.0], [787.0, 137.0, 1887.0, 1543.0, 0.620238184928894, 0.9993378520011902, 6.0], [817.0, 153.0, 1673.0, 1047.0, 0.38073745369911194, 0.999915599822998, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/108_87.13520761816095.jp...jpg.out: -------------------------------------------------------------------------------- 1 | [[327.0, 61.0, 447.0, 179.0, 0.9143534302711487, 0.9991579055786133, 3.0], [129.0, 54.0, 508.0, 619.0, 0.7678369283676147, 0.9999758005142212, 6.0], [123.0, 116.0, 405.0, 422.0, 0.6189843416213989, 0.9996929168701172, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/114_59.construction-1717...jpg.out: -------------------------------------------------------------------------------- 1 | [[610.0, 31.0, 926.0, 409.0, 0.8353585004806519, 0.9997665286064148, 2.0], [395.0, 172.0, 883.0, 640.0, 0.6423683166503906, 0.7887933254241943, 4.0], [299.0, 62.0, 911.0, 724.0, 0.37456536293029785, 0.9268847107887268, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/11_43.work-711708_960_7...jpg.out: -------------------------------------------------------------------------------- 1 | [[129.0, 105.0, 249.0, 202.0, 0.8701727986335754, 0.9999552965164185, 3.0], [44.0, 191.0, 241.0, 495.0, 0.7351419925689697, 0.8995110392570496, 4.0], [57.0, 93.0, 254.0, 705.0, 0.527186393737793, 0.9989128112792969, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/15_10.site-1536863_960_...jpg.out: -------------------------------------------------------------------------------- 1 | [[556.0, 151.0, 659.0, 267.0, 0.9830528497695923, 0.999728262424469, 5.0], [548.0, 105.0, 655.0, 388.0, 0.8792119026184082, 0.9781509637832642, 6.0], [544.0, 108.0, 600.0, 165.0, 0.746332049369812, 0.9998086094856262, 1.0], [461.0, 200.0, 507.0, 251.0, 0.6403807401657104, 0.9975935816764832, 1.0], [399.0, 223.0, 504.0, 342.0, 0.6213921904563904, 0.6983861327171326, 4.0], [389.0, 201.0, 514.0, 392.0, 0.432939350605011, 0.99228435754776, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/17_34.160728-F-VV898-05...jpg.out: -------------------------------------------------------------------------------- 1 | [[542.0, 36.0, 792.0, 317.0, 0.9175053834915161, 0.9985901713371277, 0.0], [166.0, 19.0, 794.0, 785.0, 0.9102635383605957, 0.9999617338180542, 6.0], [183.0, 109.0, 636.0, 544.0, 0.8651552200317383, 0.999438464641571, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/18_2.Man-Manufacturing-...jpg.out: -------------------------------------------------------------------------------- 1 | [[429.0, 59.0, 629.0, 247.0, 0.8844758868217468, 0.9996408224105835, 1.0], [281.0, 102.0, 332.0, 144.0, 0.8796775341033936, 0.9998583793640137, 1.0], [454.0, 29.0, 886.0, 489.0, 0.6102683544158936, 0.9999595880508423, 6.0], [296.0, 100.0, 401.0, 262.0, 0.5953809022903442, 0.9996520280838013, 6.0], [511.0, 157.0, 875.0, 462.0, 0.5207609534263611, 0.9000397324562073, 4.0], [319.0, 127.0, 391.0, 212.0, 0.44880178570747375, 0.8851988315582275, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/28_10.pexels-photo-2918...jpg.out: -------------------------------------------------------------------------------- 1 | [[490.0, 223.0, 745.0, 495.0, 0.9874625205993652, 0.9999778270721436, 0.0], [635.0, 274.0, 1126.0, 697.0, 0.802408754825592, 0.827769935131073, 4.0], [536.0, 213.0, 1153.0, 939.0, 0.5601307153701782, 0.9999926090240479, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/31_17.BP_subsea_oil_rec...jpg.out: -------------------------------------------------------------------------------- 1 | [[550.0, 17.0, 964.0, 478.0, 0.7302107810974121, 0.9911370277404785, 2.0], [61.0, 420.0, 148.0, 503.0, 0.6471499800682068, 0.9849526286125183, 2.0], [4.0, 418.0, 148.0, 689.0, 0.523597776889801, 0.9461650848388672, 6.0], [4.0, 463.0, 129.0, 628.0, 0.5113266110420227, 0.9751965999603271, 4.0], [228.0, 0.0, 943.0, 783.0, 0.4691280126571655, 0.9967879056930542, 6.0], [378.0, 34.0, 923.0, 699.0, 0.46255946159362793, 0.6147401928901672, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/50_31.WomanFactory1940s...jpg.out: -------------------------------------------------------------------------------- 1 | [[446.0, 34.0, 720.0, 320.0, 0.9751795530319214, 0.9961119294166565, 0.0], [242.0, 57.0, 726.0, 889.0, 0.7279139161109924, 0.8486228585243225, 6.0], [260.0, 220.0, 718.0, 732.0, 0.6245627403259277, 0.7141773104667664, 4.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/54_11.Welder_in_Egypt_(...jpg.out: -------------------------------------------------------------------------------- 1 | [[73.0, 226.0, 764.0, 1032.0, 0.8809224367141724, 0.9916692972183228, 4.0], [482.0, 68.0, 915.0, 427.0, 0.8395098447799683, 0.9984474778175354, 2.0], [65.0, 22.0, 895.0, 1096.0, 0.5797771215438843, 0.9999768733978271, 6.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/58_30.worker-work-build...jpg.out: -------------------------------------------------------------------------------- 1 | [[131.0, 463.0, 557.0, 1139.0, 0.9520664811134338, 0.9999889135360718, 6.0], [155.0, 514.0, 476.0, 791.0, 0.8288373947143555, 0.9998806715011597, 5.0], [411.0, 458.0, 576.0, 584.0, 0.570451021194458, 0.9930732846260071, 1.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/61_2.worker-on-construc...jpg.out: -------------------------------------------------------------------------------- 1 | [[301.0, 444.0, 454.0, 848.0, 0.7669716477394104, 0.9987176656723022, 6.0], [318.0, 508.0, 439.0, 667.0, 0.7442220449447632, 0.9989979863166809, 4.0], [364.0, 444.0, 421.0, 503.0, 0.42340296506881714, 0.9950201511383057, 1.0], [224.0, 1172.0, 337.0, 1356.0, 0.3763265907764435, 0.8346812129020691, 6.0], [244.0, 1184.0, 296.0, 1219.0, 0.30666273832321167, 0.9901644587516785, 1.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/79_32.site-1536859_960_...jpg.out: -------------------------------------------------------------------------------- 1 | [[250.0, 232.0, 395.0, 396.0, 0.9887076616287231, 0.9998338222503662, 5.0], [554.0, 169.0, 715.0, 617.0, 0.9693436622619629, 0.9999908208847046, 6.0], [239.0, 164.0, 406.0, 595.0, 0.966259241104126, 0.9999823570251465, 6.0], [555.0, 228.0, 693.0, 398.0, 0.95257169008255, 0.9931094646453857, 4.0], [550.0, 13.0, 612.0, 88.0, 0.9028677344322205, 0.9998948574066162, 1.0], [291.0, 165.0, 351.0, 231.0, 0.8822859525680542, 0.9948705434799194, 1.0], [519.0, 75.0, 660.0, 235.0, 0.7573475241661072, 0.8598764538764954, 5.0], [567.0, 145.0, 644.0, 237.0, 0.6224001049995422, 0.9756877422332764, 0.0], [583.0, 164.0, 641.0, 232.0, 0.48600587248802185, 0.9986501336097717, 0.0]] -------------------------------------------------------------------------------- /data/test_samples/demo_raw_output/README.md: -------------------------------------------------------------------------------- 1 | ## Output data examples 2 | 3 | This folder contains raw output generated by PPE Detector model using `Batch Transform` approach. -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import random 2 | import matplotlib.pyplot as plt 3 | import matplotlib.image as mpimg 4 | 5 | 6 | colors = [ 7 | # Bare Head 8 | [0.716, 0.170, 0.427], 9 | 10 | # Helmet 11 | [0.388, 0.631, 0.111], 12 | 13 | # Welding Mask 14 | [0.098, 0.680, 0.468], 15 | 16 | # Ear Protection 17 | [0.163, 0.075, 0.997], 18 | 19 | # NO Visibility Vest 20 | [0.849, 0.471, 0.491], 21 | 22 | # High Visibility Vest 23 | [0.595, 0.554, 0.006], 24 | 25 | # Person 26 | [0.699, 0.193, 0.917] 27 | ] 28 | 29 | 30 | classes = ['Bare Head', 'Helmet', 'Welding Mask', 'Ear Protection', 31 | 'NO Visibility Vest', 'High Visibility Vest', 'Person'] 32 | 33 | 34 | def visualize_detection(img_file, dets, save_path=None): 35 | img=mpimg.imread(img_file) 36 | plt.imshow(img) 37 | height = img.shape[0] 38 | width = img.shape[1] 39 | 40 | for det in dets: 41 | x0, y0, x1, y1, score, _, klass = det 42 | 43 | cls_id = int(klass) 44 | xmin = x0 45 | ymin = y0 46 | xmax = x1 47 | ymax = y1 48 | rect = plt.Rectangle((xmin, ymin), xmax - xmin, 49 | ymax - ymin, fill=False, 50 | edgecolor=colors[cls_id], 51 | linewidth=3.5) 52 | plt.gca().add_patch(rect) 53 | class_name = str(cls_id) 54 | if classes and len(classes) > cls_id: 55 | class_name = classes[cls_id] 56 | plt.gca().text(xmin, ymin - 2, 57 | '{:s} {:.3f}'.format(class_name, score), 58 | bbox=dict(facecolor=colors[cls_id], alpha=0.3), 59 | fontsize=12, color='white') 60 | plt.axis('off') 61 | 62 | if save_path is not None: 63 | plt.savefig(save_path, bbox_inches='tight') 64 | 65 | plt.show() 66 | --------------------------------------------------------------------------------