{"id":13747195,"url":"https://github.com/arunponnusamy/cvlib","last_synced_at":"2025-05-09T08:31:55.212Z","repository":{"id":37549698,"uuid":"122620534","full_name":"arunponnusamy/cvlib","owner":"arunponnusamy","description":"A simple, high level, easy to use, open source Computer Vision library for Python.","archived":false,"fork":false,"pushed_at":"2023-10-06T12:56:53.000Z","size":12910,"stargazers_count":657,"open_issues_count":28,"forks_count":128,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-14T19:17:52.273Z","etag":null,"topics":["computer-vision","deep-learning","image-processing","machine-learning","python"],"latest_commit_sha":null,"homepage":"http://arunponnusamy.com/cvlib/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arunponnusamy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-23T12:47:41.000Z","updated_at":"2025-03-28T06:41:13.000Z","dependencies_parsed_at":"2023-10-20T17:49:04.861Z","dependency_job_id":null,"html_url":"https://github.com/arunponnusamy/cvlib","commit_stats":{"total_commits":99,"total_committers":5,"mean_commits":19.8,"dds":0.101010101010101,"last_synced_commit":"e78b1fd9c235454c6644dcc5d91fa216f1b51a9d"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arunponnusamy%2Fcvlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arunponnusamy%2Fcvlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arunponnusamy%2Fcvlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arunponnusamy%2Fcvlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arunponnusamy","download_url":"https://codeload.github.com/arunponnusamy/cvlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253217034,"owners_count":21873001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","deep-learning","image-processing","machine-learning","python"],"created_at":"2024-08-03T06:01:19.863Z","updated_at":"2025-05-09T08:31:55.202Z","avatar_url":"https://github.com/arunponnusamy.png","language":"Python","funding_links":["https://buymeacoffee.com/arunponnusamy"],"categories":["Python"],"sub_categories":[],"readme":"[![Downloads](https://static.pepy.tech/personalized-badge/cvlib?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=blue\u0026left_text=pip%20installs)](https://pepy.tech/project/cvlib) [![PyPI](https://img.shields.io/pypi/v/cvlib.svg?color=blue)](https://pypi.org/project/cvlib/)\n\n# cvlib\nA simple, high level, easy-to-use open source Computer Vision library for Python.\n\n## Installation\n\n### Installing dependencies\n\nProvided the below python packages are installed, cvlib is completely pip installable.\n\n* OpenCV\n* TensorFlow\n\nIf you don't have them already installed, you can install through pip\n\n`pip install opencv-python tensorflow` \n\n#### Optional\nor you can compile them from source if you want to enable optimizations for your specific hardware for better performance.\nIf you are working with GPU, you can install `tensorflow-gpu` package through `pip`. Make sure you have the necessary Nvidia drivers  installed preoperly (CUDA ToolKit, CuDNN etc). \n\nIf you are not sure, just go with the cpu-only `tensorflow` package.\n\nYou can also compile OpenCV from source to enable CUDA optimizations for Nvidia GPU.\n\n### Installing cvlib\n\n`pip install cvlib`\n\nTo upgrade to the newest version\n`pip install --upgrade cvlib`\n\n#### Optional\nIf you want to build cvlib from source, clone this repository and run the below commands.\n```\ngit clone https://github.com/arunponnusamy/cvlib.git\ncd cvlib\npip install .\n```\n\n**Note: Compatability with Python 2.x is not officially tested.**\n\n## Face detection\nDetecting faces in an image is as simple as just calling the function `detect_face()`. It will return the bounding box corners and corresponding confidence for all the faces detected.\n### Example :\n\n```python\nimport cvlib as cv\nfaces, confidences = cv.detect_face(image)\n```\nSeriously, that's all it takes to do face detection with `cvlib`. Underneath it is using OpenCV's `dnn` module with a pre-trained caffemodel to detect faces.\n\nTo enable GPU\n```python\nfaces, confidences = cv.detect_face(image, enable_gpu=True)\n```\n\nCheckout `face_detection.py` in `examples` directory for the complete code.\n\n### Sample output :\n\n![](examples/images/face_detection_output.jpg)\n\n## Gender detection\nOnce face is detected, it can be passed on to `detect_gender()` function to recognize gender. It will return the labels (man, woman) and associated probabilities.\n\n### Example\n\n```python\nlabel, confidence = cv.detect_gender(face)\n```\n\nUnderneath `cvlib` is using an AlexNet-like model trained on [Adience dataset](https://talhassner.github.io/home/projects/Adience/Adience-data.html#agegender) by Gil Levi and Tal Hassner for their [CVPR 2015 ](https://talhassner.github.io/home/publication/2015_CVPR) paper.\n\nTo enable GPU\n```python\nlabel, confidence = cv.detect_gender(face, enable_gpu=True)\n```\n\nCheckout `gender_detection.py` in `examples` directory for the complete code.\n\n### Sample output :\n\n![](examples/images/gender_detection_output.jpg)\n\n## Object detection\nDetecting common objects in the scene is enabled through a single function call `detect_common_objects()`. It will return the bounding box co-ordinates, corrensponding labels and confidence scores for the detected objects in the image.\n\n### Example :\n\n```python\nimport cvlib as cv\nfrom cvlib.object_detection import draw_bbox\n\nbbox, label, conf = cv.detect_common_objects(img)\n\noutput_image = draw_bbox(img, bbox, label, conf)\n```\nUnderneath it uses [YOLOv4](https://github.com/AlexeyAB/darknet) model trained on [COCO dataset](http://cocodataset.org/) capable of detecting 80 [common objects](https://github.com/arunponnusamy/object-detection-opencv/blob/master/yolov3.txt) in context.\n\nTo enable GPU\n```python\nbbox, label, conf = cv.detect_common_objects(img, enable_gpu=True)\n```\n\nCheckout `object_detection.py` in `examples` directory for the complete code.\n\n### Real time object detection\n`YOLOv4` is actually a heavy model to run on CPU. If you are working with real time webcam / video feed and doesn't have GPU, try using `tiny yolo` which is a smaller version of the original YOLO model. It's significantly fast but less accurate.\n\n```python\nbbox, label, conf = cv.detect_common_objects(img, confidence=0.25, model='yolov4-tiny')\n```\nCheck out the [example](examples/object_detection_webcam.py) to learn more. \n\nOther supported models: YOLOv3, YOLOv3-tiny.\n\n### Custom trained YOLO weights\nTo run inference with custom trained YOLOv3/v4 weights try the following\n```python\nfrom cvlib.object_detection import YOLO\n\nyolo = YOLO(weights, config, labels)\nbbox, label, conf = yolo.detect_objects(img)\nyolo.draw_bbox(img, bbox, label, conf)\n```\nTo enable GPU\n```python\nbbox, label, conf = yolo.detect_objects(img, enable_gpu=True)\n```\n\nCheckout the [example](examples/yolo_custom_weights_inference.py) to learn more.\n\n### Sample output :\n\n![](examples/images/object_detection_output.jpg)\n\n## Utils\n### Video to frames\n`get_frames( )` method can be helpful when you want to grab all the frames from a video. Just pass the path to the video, it will return all the frames in a list. Each frame in the list is a numpy array.\n```python\nimport cvlib as cv\nframes = cv.get_frames('~/Downloads/demo.mp4')\n```\nOptionally you can pass in a directory path to save all the frames to disk.\n```python\nframes = cv.get_frames('~/Downloads/demo.mp4', '~/Downloads/demo_frames/')\n```\n\n### Creating gif\n`animate( )` method lets you create gif from a list of images. Just pass a list of images or path to a directory containing images and output gif name as arguments to the method, it will create a gif out of the images and save it to disk for you.\n\n```python\ncv.animate(frames, '~/Documents/frames.gif')\n```\n\n## Sponsor\nDeveloping and maintaining open source projects takes a lot of time and effort. If you are getting value out of this project, consider supporting my work by simply [buying me a coffee](https://buymeacoffee.com/arunponnusamy) (one time or every month).\n\n## License\ncvlib is released under MIT license.\n\n## Help\nFor bugs and feature requests, feel free to file a [GitHub issue](https://github.com/arunponnusamy/cvlib/issues). (Make sure to check whether the issue has been filed already) \n\nFor usage related how-to questions, please create a new question on [StackOverflow](https://stackoverflow.com/questions/tagged/cvlib) with the tag `cvlib`.\n\n## Community\nJoin the official [Discord Server](https://discord.gg/CHHQJZGWfh) or [GitHub Discussions](https://github.com/arunponnusamy/cvlib/discussions) to talk about all things cvlib.\n\n## Citation\nIf you find cvlib helpful in your work, please cite the following\n```BibTex\n@misc{ar2018cvlib,\n  author =       {Arun Ponnusamy},\n  title =        {cvlib - high level Computer Vision library for Python},\n  howpublished = {\\url{https://github.com/arunponnusamy/cvlib}},\n  year =         {2018}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farunponnusamy%2Fcvlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farunponnusamy%2Fcvlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farunponnusamy%2Fcvlib/lists"}