Q:

Add numba to a python script

I have tried to apply numba to the following script to decrease the running time, but have not succeeded. 
Any suggestions on how to do that? I am working in python 3.7 in spyder/anaconda.
import timeit
start = timeit.default_timer()

from PIL import Image, ImageDraw # Importerer biblioteket

# Load image:
input_image = Image.open("beatles.jpg") # Loads an image from the hard drive
input_pixels = input_image.load()

# Box Blur kernel
box_kernel = [[1 / 9, 1 / 9, 1 / 9], [1 / 9, 1 / 9, 1 / 9], [1 / 9, 1 / 9, 1 / 9]]

# Select kernel here:
kernel = box_kernel

# Middle of the kernel
offset = len(kernel) // 2

# Creating the output image
output_image = Image.new("RGB", input_image.size)
draw = ImageDraw.Draw(output_image)

# Beregne konvolusjon mellom intensity (original bilde) og  kernel 
for x in range(offset, input_image.width - offset):
    for y in range(offset, input_image.height - offset):
        acc = [0, 0, 0]
        for a in range(len(kernel)):
            for b in range(len(kernel)):
                xn = x + a - offset
                yn = y + b - offset
                pixel = input_pixels[xn, yn]
                acc[0] += pixel[0] * kernel[a][b]
                acc[1] += pixel[1] * kernel[a][b]
                acc[2] += pixel[2] * kernel[a][b]

draw.point((x, y), (int(acc[0]), int(acc[1]), int(acc[2])))

output_image.save("Beatles box blur.png")

stop = timeit.default_timer()

print('Time: ', stop - start)  

A:

I made something quick here, hope it can get you started:
import time
import numpy as np

from numba import jit

def numba_off(offset, width, height, kernel):
    for x in range(offset, width - offset):
        for y in range(offset, height - offset):
            acc = [0, 0, 0]
            for a in range(len(kernel)):
                for b in range(len(kernel)):
                    pixel = [1, 1, 1]
                    acc[0] += pixel[0] * kernel[a][b]
                    acc[1] += pixel[1] * kernel[a][b]
                    acc[2] += pixel[2] * kernel[a][b]

@jit(nopython=True)
def numba_on(offset, width, height, kernel):
    for x in range(offset, width - offset):
        for y in range(offset, height - offset):
            acc = [0, 0, 0]
            for a in range(len(kernel)):
                for b in range(len(kernel)):
                    pixel = [1, 1, 1]
                    acc[0] += pixel[0] * kernel[a][b]
                    acc[1] += pixel[1] * kernel[a][b]
                    acc[2] += pixel[2] * kernel[a][b]

box_kernel = np.array([[1 / 9, 1 / 9, 1 / 9], [1 / 9, 1 / 9, 1 / 9], [1 / 9, 1 / 9, 1 / 9]])
kernel = box_kernel
offset = len(kernel) // 2

start = time.time()
numba_off(offset, 1000, 1000, kernel)
end = time.time()
print("Elapsed (without) = %s" % (end - start))

start = time.time()
numba_on(offset, 1000, 1000, kernel)
end = time.time()
print("Elapsed (with compilation) = %s" % (end - start))
start = time.time()
numba_on(offset, 1000, 1000, kernel)
end = time.time()
print("Elapsed (after compilation) = %s" % (end - start))

You should be able to build on that.
And it might be good for you to read something like this: 5 minute numba guide

