prediction for cnn+lstm model always show same result when trying to other video

Viewed 38

I'm trying to test my model on video for prediction.

I want to make prediction using my cnn(alexnet)+lstm model on a video that I have, but when it runs, the prediction always showing result at 0 even tho i keep changing my video to see other result, but it always have the same result when i have 5 class for prediction

Here is my code:

model_path = 'Model/AlexNet_LSTM_10Frame_Cropped.h5'
model = models.load_model(model_path)
vid = cv2.VideoCapture("Data Fix/Data16_133.mp4")

while(vid.isOpened()):
    ret, frame = vid.read()
    vid.set(3, 480)
    vid.set(4, 240)
    start = time.time()
    if ret == True:
        total_frame += 1
        draw = frame.copy()
        draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)
        scale_percent = 20 # percent of original size
        width = 224
        height = width
        dim = (width, height)
        frame_set = cv2.resize(draw, dim, interpolation = cv2.INTER_AREA)
        frame_set=np.arange(10*width*height*3).reshape(10,width, height, 3)
        frame_set.reshape(10, width, height, 3).shape
        frame_set = np.expand_dims(frame_set, axis=0)
        result=model.predict_on_batch(frame_set)

        cv2.imshow('Result', result)
        print(result)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break            

vid.release()
cv2.destroyAllWindows()

does anyone know how do i implement my cnn+lstm model to a video?did my mistake on the program that i made or my mistake at when i making the model?

currently I'm trying this tutorial to make the model and how I put the dataset path are the same like in this tutorial, the different are I didn't use the MobileNet transfer learning, I modified it using AlexNet model but not transfer learning.

i would be grateful if someone have the experience in this field and helping me

thank you so much

0 Answers
Related