File size: 1,309 Bytes
248b38d
092ff29
ea1c7b0
3e6e09c
248b38d
ffd8223
 
248b38d
a385b9c
092ff29
a6ff839
092ff29
 
 
a6ff839
092ff29
 
 
a6ff839
 
a385b9c
 
092ff29
a385b9c
092ff29
a6ff839
248b38d
 
 
 
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
import streamlit as st
# import torch
# from transformers import AutoProcessor, UdopForConditionalGeneration
# from datasets import load_dataset

# processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True)
# model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")

st.title("CIC Demo (by ITT)")
st.write("Select or upload a document (/an image) to test the model.")

# Image selection
uploaded_files = st.file_uploader("Upload document(s) [/image(s)]:", type=["docx", "pdf", "jpg", "jpeg", "png"], accept_multiple_files=True)
selected_file = st.selectbox("Select a document (/an image):", uploaded_files, format_func=lambda file: file.name if file else "None")

# Display selected image
if selected_file is not None and selected_file != "None":
    st.image(selected_file, caption="Selected Image")

# Model testing button
testButton = st.button("Test Model")
if testButton and selected_file != "None":
    st.write("Testing the model with the selected image...")
elif testButton and selected_file == "None":
    st.write("Please upload and select an image.")

# encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")

# predicted_ids = model.generate(**encoding)
# print(processor.batch_decode(predicted_ids, skip_special_tokens=True)[0])