File size: 1,222 Bytes
a1551fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
from generator2 import response
from PIL import Image

st.title("Chem 210 Autograder - Manual Upload")

if "messages" not in st.session_state:
    st.session_state.messages = []

for message in st.session_state.messages:
    with st.chat_message(message["role"]):
        st.markdown(message["content"])

# Use file_uploader for image input
image_input1 = st.file_uploader("Upload the solution molecule", type=["png", "jpg", "jpeg"])
image_input2 = st.file_uploader("Upload the desired molecule to be graded", type=["png", "jpg", "jpeg"])

if st.button("Submit"):
    if image_input1 and image_input2:
        # Open and convert images to RGB format
        image1 = Image.open(image_input1).convert('RGB')
        image2 = Image.open(image_input2).convert('RGB')

        # Process images using your response function
        answer = response(image1, image2)

        # Display results in chat style
        st.session_state.messages.append({"role": "user", "content": "User uploaded images."})
        with st.chat_message("AI"):
            st.markdown(answer)
        st.session_state.messages.append({"role": "AI", "content": answer})
    else:
        st.warning("Please upload two images.")