Git Product home page Git Product logo

comparing-numba-less-and-numba-flavored-version's Introduction

Comparing a numba-less version and numba-flavored version of the same code base

I recently added im2dhisteq to my repository and because it was very slow, I searched for a new way to make my code run faster, as I was already using numpy built-in functions and there were no (at least easy) other way to optimize the code using just numpy.
I recently found out about numba, which is advertised to run my codes 1000 times faster, but as I later found out the degree of that is actually very dependant on your code. After reading through their website and through a long series of trials and erros I learned how to write a code that is numba-friendly and is satisfyingly faster than my base code.
In my repository, in addition to the numba-flavord versions, I released the numba-less versions, which are accessible here: im2dhisteq and imhist. You can check them out and compare them to come to a base understanding of how numba-friendly codes looks like.

Reproducing the results

This is just a showcase, but if you want to check its authenticity, firstly you need to download and extract both versions of numba-less and numba-flavord and follow instructions.
Firstly, run this command in a terminal pip install -e im2dhist-0.1.0.9/. &> /dev/null; pip install -e im2dhisteq-0.0.2/. &> /dev/null to install the numba-less version. After running the bellow code in a jupyter-notebook , enter this command in a terminal to install the numba-flavored version: pip install -e im2dhist &> /dev/null; pip install -e im2dhisteq &> /dev/null and run the bellow code again.

import numpy as np
import cv2
import im2dhisteq

img = cv2.imread('cloudy-day.jpg')
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
v = hsv[:, :, 2].copy()

%timeit vv = im2dhisteq.im2dhisteq(v)

Results

results
Showing that it's about 21 times faster in my case ๐Ÿ™‡

comparing-numba-less-and-numba-flavored-version's People

Contributors

mamdasn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.