I have a flask website. I was to make prediction images using the model that I build in Google Collab. In this, I have 25 classes and I took 3 classes for testing its work or not. I have already run it but when I go to the predict pages it seems to get the error '**jinja2.exceptions.UndefinedError: 'predictions' is undefined**' Can anyone help me. Thank u

The Python Code:

```
with open('CNN.pth','rb') as file:
    model=torch.load('CNN.pth',map_location='cpu')

classes=['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24']

def predict(filename,model):
    img=load_img(filename,target_size=(32,32))
    img=img_to_array(img)
    img=img.reshape(1,32,32,3)

    img = img.astype('float32')
    img = img/255.0
    result = model.predict(img)

    dict_result = {}
    for i in range(25):
        dict_result[result[0][i]] = classes[i]

    res = result[0]
    res.sort()
    res = res[::-1]
    prob = res[:3]

    prob_result = []
    class_result = []
    for i in range(3):
        prob_result.append((prob[i]*100).round(2))
        class_result.append(dict_result[prob[i]])

    return class_result , prob_result

@app.route('/predict' , methods = ['GET' , 'POST'])
def success():
    error = ''
    target_img = os.path.join(os.getcwd() , 'static/images')
    if request.method == 'POST':
        if (request.files):
            file = request.files['file']
            if file and allowed_file(file.filename):
                file.save(os.path.join(target_img , file.filename))
                img_path = os.path.join(target_img , file.filename)
                img = file.filename

                class_result , prob_result = predict(img_path , model)

                predictions = {
                      "class1":class_result[0],
                        "class2":class_result[1],
                        "class3":class_result[2],
                        "prob1": prob_result[0],
                        "prob2": prob_result[1],
                        "prob3": prob_result[2],
                }

            else:
                error = "Please upload images of jpg , jpeg and png extension only"

            if(len(error) == 0):
                return  render_template('predict.html' , img  = img , predictions = predictions)
            else:
                return render_template('home.html' , error = error)

    else:
        return render_template('home.html')

```

Index.html

```
<tr>
                <th>Class</th>
                <th>Probability</th>
            </tr>
            <tr>
              <th>{{predictions.class1}}</th>
                <th>{{predictions.prob1}}</th>
            </tr>
            <tr>
              <th>{{predictions.class2}}</th>
                <th>{{predictions.prob2}}</th>
            </tr>
            <tr>
              <th>{{predictions.class3}}</th>
                <th>{{predictions.prob3}}</th>
            </tr>

```