Greyed out (replica of a section) shown in the screen

On uploading an image from the local, there is a greyed out replica of that file upload component seen. I am unable to understand what is actually causing that issue. Could anyone kindly let me know if there is a work around for this.

Kindly refer to the image for reference.

Hi Saksham :grinning_face_with_smiling_eyes:

Could you share the link to your app on Streamlit Sharing? I’m unable to re-produce this issue on my end – getting a look at the code will help with debugging.

Best, :balloon:
Snehan

Hi Snehan , I haven’t hosted the web app anywhere as of now. Hence sharing the piece of code below:

def app():
    image1 = st.file_uploader('Choose original signature..')
    if image1:
        image1_bytes = np.asarray(bytearray(image1.read()), dtype=np.uint8)
        image1 = cv2.imdecode(image1_bytes, 1)
        st.image(image1, channels="BGR")
        image1 = cv2.resize(image1, (224, 224))

    image2 = st.file_uploader('Choose signature to be verified..')
    if image2:
        image2_bytes = np.asarray(bytearray(image2.read()), dtype=np.uint8)
        image2 = cv2.imdecode(image2_bytes, 1)
        st.image(image2, channels="BGR")
        image2 = cv2.resize(image2, (224, 224))

    option = st.sidebar.selectbox('Select the algorithm to be used for feature extraction',
                                  ['Select an option', 'VGG16', 'VGG19', 'ResNet50'], 0)

    if option != 'Select an option':
        if option == 'VGG16':
            image1_feature = vgg16_feature_embedding(image1)
            image2_feature = vgg16_feature_embedding(image2)
            cosine_similarity = similarity_score(image1_feature, image2_feature)
            cosine_similarity = round(cosine_similarity * 100, 2)
            st.write('The matching score for the signatures is:')
            st.success(cosine_similarity)
            if cosine_similarity < threshold:
                st.write("The signatures don't match!!")
            else:
                st.success("The signatures match!!")

        elif option == 'VGG19':
            image1_feature = vgg19_feature_embedding(image1)
            image2_feature = vgg19_feature_embedding(image2)
            cosine_similarity = similarity_score(image1_feature, image2_feature)
            cosine_similarity = round(cosine_similarity * 100, 2)
            st.write('The matching score for the signatures is:')
            st.success(cosine_similarity)
            if cosine_similarity < threshold:
                st.write("The signatures don't match!!")
            else:
                st.success("The signatures match!!")

        else:
            image1_feature = resnet50_feature_embedding(image1)
            image2_feature = resnet50_feature_embedding(image2)
            cosine_similarity = similarity_score(image1_feature, image2_feature)
            cosine_similarity = round(cosine_similarity * 100, 2)
            st.write('The matching score for the signatures is:')
            st.success(cosine_similarity)
            if cosine_similarity < threshold:
                st.write("The signatures don't match!!")
            else:
                st.success("The signatures match!!")

Kindly check if this helps.

Hi @Saksham :slightly_smiling_face:

Thank you for sharing your code! Are you sure that the greyed out portion is a replica and not the st.file_uploader associated with image1? According to your code, there are two of them - one below the other. :mag:

In your screenshot, the first image is Sig8.JPG and the second image is Sig10.JPG. They don’t seem to be replicas. However, I suspect it might be taking a while to upload files after a few runs as the vvg16 and resnet models are taking up most of your RAM. I’m not 100% sure, but I suspect loading the models into memory over and over again causes a bottleneck.

Do you run into this issue when you first open the app? i.e exit the app → kill all the python processes → run your app. Or does it occur once you’ve uploaded 3+ images and performed feature extraction? :thinking:

1 Like