Kernel Restart Issue When Loading TFLite Model on Pynq-Z2 Board

Hello Pynq Community,

I am currently working on a project where I need to run a TensorFlow Lite (TFLite) model on my Pynq-Z2 board. However, I am encountering an issue where the Jupyter notebook kernel keeps restarting when I attempt to load the model.

Here are the details of my setup and the steps I have taken so far:

.Hardware: Pynq-Z2 board
.Software: Jupyter Notebook, tflite_runtime, OpenCV, NumPy
.Model Path: /home/xilinx/code_using_unet_256.tflite
.jupyter notebook Code:

import tflite_runtime.interpreter as tflite
import numpy as np
import cv2
import matplotlib.pyplot as plt

Path to your TFLite model

tflite_model_path = “/home/xilinx/code_using_unet_256.tflite”

Load TFLite model and allocate tensors

def load_model(model_path):
try:
print(“Loading TFLite model…”)
interpreter = tflite.Interpreter(model_path=model_path)
print(“Allocating tensors…”)
interpreter.allocate_tensors()
print(“Tensors allocated successfully.”)
return interpreter
except Exception as e:
print(“Error during model loading or tensor allocation:”, str(e))
return None

interpreter = load_model(tflite_model_path)
if interpreter:
print(“Model loaded successfully”)
else:
print(“Failed to load model”)

Problem:
Every time I run the code to load the TFLite model, the kernel restarts automatically with the message: “The kernel appears to have died. It will restart automatically.”

Questions:

1.Has anyone faced a similar issue when working with TFLite models on the Pynq-Z2 board?
2.Are there any specific configurations or optimizations required to successfully load and run TFLite models on Pynq-Z2?
3.Any advice on additional troubleshooting steps or resources would be greatly appreciated.
Thank you for your help!