Progress bar that update after completion of each function in Django

Viewed 208

I make an OCR application which take an input image from user and do this following steps (In order):

  1. Image Processing
  2. Bounding Box
  3. Character Segmentation
  4. Predicting each characters

But Since this all above steps is taking too much time, so I decided to implement a progress bar which show how much process is done to users. But I am new to Django and I read about celery-progress-bar. Ans I can't figure out how do I use this in my app.

Here is what I thought, what my view.py should look like:

def my_function(request): 
    # Here I want to start progress bar
    ....
    cleared_image = image_processing(image) # Image Processing
    segmented = character_segmentation(cleared_image) # Segmented Characters as list (in sorted)
    .....
    predicted = [] # This list will store prediction of each character
    for character in segmented:
         ....
         prediction = predict(obj.picture)
         predicted.append(prediction)
         ### Here I want to Update Progress bar
         ....

def image_processing(image):
    # Correct skew and Do Image Processing
    ### Here I want to Update Progress bar 
    return resulted_image

def character_segmentation(image):
    #Do Bounding Box and character Segmentation
    ### Here I want to Update Progress bar
    return list_of_characters
0 Answers
Related