import streamlit as st from PIL import Image import kosmos kosmos.load_model() st.title('KOSMOS2 Model Evaluation') uploaded_file = st.file_uploader("Choose an image...", type="jpg") if uploaded_file is not None: try: image = Image.open(uploaded_file) st.image(image, caption='Uploaded Image.', use_column_width=True) st.write("") prompt = st.text_input(f"Detect the main object in the image. The image is a") if st.button('Classify'): st.write(f"User: {prompt}") with st.spinner('Processing...'): label = kosmos.single_image_classification(image, prompt, 50) st.write(f"Model: {label}") except Exception as e: st.error(f"An error occurred: {e}")