projekt_widzenie/main.py

35 lines
998 B
Python
Raw Normal View History

2023-01-21 16:22:16 +01:00
import streamlit as st
from process_video import segment_video, classify
from io import StringIO
import cv2 as cv
import tempfile
import numpy as np
import tensorflow as tf
2023-01-21 16:22:16 +01:00
if __name__ == "__main__":
model = tf.keras.models.load_model('model_pred/VGG16_sign_char_detection_model')
st.set_page_config(
page_title="Projekt widzenie"
)
st.title("Projekt rozpoznawanie liter z alfabetu znaków migowych z wideo")
2023-01-21 16:22:16 +01:00
st.write('Załaduj film')
2023-01-29 17:03:38 +01:00
upload_movie = st.file_uploader("Wybierz film", type=["mp4"])
2023-01-29 17:03:38 +01:00
if upload_movie:
st.write("Film się ładuje.....")
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(upload_movie.read())
video_cap = cv.VideoCapture(tfile.name)
result, num = segment_video(video_cap, fps=1.5)
st.write(f"Załadowano {num} klatek")
for img in result:
img2= cv.resize(img,dsize=(224,224))
img_np = np.asarray(img2)
classification = classify(img_np[:,:,::-1], model)
st.image(img[:,:,::-1])
st.write(classification)