Unable to import cv2 to deloy streamlit

This is my code

import sys
import streamlit as st
import numpy as np
from PIL import ImageTk, Image
import os.path
import cv2
import joblib
from sklearn.svm import LinearSVC
st.title("Nhan dang khuan matπŸ‘©πŸ§‘β€πŸ¦°πŸ‘¨β€πŸ¦°")
detector = cv2.FaceDetectorYN.create(
    (320, 320),
detector.setInputSize((320, 320))
recognizer = cv2.FaceRecognizerSF.create(
svc = joblib.load('svc.pkl')
mydict = ['BanNinh','BanThanh','ThayDuc']
image_file = st.file_uploader('Open Image πŸ–Ό', type=['PNG','JPG','BMP'])
if image_file is not None:
    file_name = image_file.name
    file_name = "test/" + file_name
    col1, col2 = st.columns(2)
    with col1:
    if st.button('Nhan Dang'):
        with col2:
            img_array = cv2.imread(file_name)
            faces = detector.detect(img_array)
            face_align = recognizer.alignCrop(img_array, faces[1][0])
            face_feature = recognizer.feature(face_align)
            test_prediction = svc.predict(face_feature)
            result = mydict[test_prediction[0]]
            cv2.imwrite('digit1.jpg', img_array)
            imge1 = Image.open('digit1.jpg')
            st.image(imge1, caption='')

Hey @loctp2003,

Thanks for sharing your question! Can you please share the requirements file and the full error message that you’re seeing?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.