Other Parts Discussed in Thread: AM69A
Tool/software:
I've deployed the compiled model, and the detections are accurate, but the FPS is only 11. Is this expected performance, or is there an issue? I'm running it on an AM69A processor, and I trained the model using Edge AI Tensor Lab.
import onnxruntime as ort import cv2 import numpy as np import time model_path = "/zken/od-yolov7/model/yolov7_l_standalone_kenny_yuv_input.onnx" video_path='/zken/data/fast.mp4' artifacts_folder='/zken/od-yolov7/artifacts' providers=['TIDLExecutionProvider', 'CPUExecutionProvider'] so = ort.SessionOptions() runtime_options = { "artifacts_folder": artifacts_folder, } provider_options = [runtime_options, {}] session = ort.InferenceSession(model_path, providers=providers, provider_options=provider_options, sess_options=so) print("Active providers:", session.get_providers()) input_name = session.get_inputs()[0].name output_names = [output.name for output in session.get_outputs()] cap = cv2.VideoCapture(video_path) if not cap.isOpened(): print("Error: Could not open video.") # FPS calculation variables frame_count = 0 fps_start_time = time.time() fps = 0 while True: ret, frame = cap.read() if not ret: break time_start=time.time() input_image=cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) input_image=cv2.resize(input_image, (640, 640)).transpose(2, 0, 1) input_image=np.expand_dims(input_image, axis=0).astype(np.float32) input_image/=255.0 outputs=session.run(output_names, {input_name: input_image}) # end_time=time.time()-time_start # print(f"Inference time: {end_time:.2f} seconds") # FPS calculation frame_count += 1 elapsed_time = time.time() - fps_start_time # Update FPS every second if elapsed_time >= 1.0: fps = frame_count / elapsed_time frame_count = 0 fps_start_time = time.time() print(f"FPS: {fps:.2f}") # # Display FPS on the frame # cv2.putText(frame, f"FPS: {fps:.2f}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2) # # Display the frame # cv2.imshow('Video with FPS', frame) # # Break on 'q' key press # if cv2.waitKey(1) & 0xFF == ord('q'): # break # Release resources cap.release() # cv2.destroyAllWindows()