Thread 'async_media_processor_0': missing ReportContext

Hey Guys !

I’m trying to build a sign language to text conversion web app using streamlit and OpenCV. Basically, the tool predicts the alphabet done by the user and concatenates it to a string variable and displays that string with the live changes.

Sample Terminal Output :
B
BA
BAL
BALL

So, I want to print this string to Streamlit using the same write command .

I used -
widget = st.empty()
widget.write(string)

Code :

widget = st.empty()

def process(image): 
    global s
    image = cv2.flip(image, 1)
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)   
    frame=image
    image.flags.writeable = False
    results = hands.process(frame)
    image.flags.writeable = True   
    image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
    cv2.rectangle(image,(0,0),(400,100),(255, 255, 255),-1)
    cv2.rectangle(image,(0,428),(704,528),(255, 255, 255),-1)
    if results.multi_hand_landmarks:
        cleaned_landmark = data_clean(results.multi_hand_landmarks)
       
        if cleaned_landmark:
            
            clf = joblib.load(Model Path)      
            y_pred = clf.predict(cleaned_landmark)
            classes_x=np.argmax(y_pred)
            image = cv2.putText(image, str(y_pred), (0,70),cv2.FONT_HERSHEY_SIMPLEX,  3, (0,0,0), 2, cv2.LINE_AA)
            d[y_pred[0]]+=1
            if d[y_pred[0]]>20:
                if (y_pred[0] in d1.keys()):
                    if (s==""):
                        s+=d1[y_pred[0]]
                    elif (s[-1] in ascii_uppercase):
                        s+=" "+d1[y_pred[0]]
                    else:
                        s+=d1[y_pred[0]]
                    d[y_pred[0]]=0
                elif (y_pred[0]=='BACKSPACE'):
                    s=s[:-1]
                    d[y_pred[0]]=0
                elif (y_pred[0]=='SPACE'):
                    if ((s[-1] in ascii_uppercase ) or (s[-1] in ('1234567890'))):
                        s+=" "
                        d[y_pred[0]]=0
                else:
                    s+=y_pred[0]
                    d[y_pred[0]]=0
            print("**************************************************\n")
            print(s)
            print("**************************************************\n")
            widget.write(s)
                                  

    return image

But I’m getting an Error saying :

The Output in Terminal is not getting printed in Streamlit !

Link To My Repo - Github Link

Help me out with this !

Since you are working with global s are you able to write to your app page immediately after calling the function instead of within it?

Got it ! Thanks A Lot …