Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,27 @@
|
|
1 |
import streamlit as st
|
2 |
-
# import
|
3 |
# from transformers import AutoProcessor, UdopForConditionalGeneration
|
4 |
# from datasets import load_dataset
|
5 |
|
6 |
# processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True)
|
7 |
# model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
|
8 |
|
9 |
-
st.title("Image Selection and Upload")
|
10 |
-
st.write("Select or upload an image to test the model.")
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
st.image(uploaded_file, caption="Uploaded Image")
|
17 |
|
18 |
# Model testing button
|
19 |
-
if st.button("Test Model"):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
elif image_option == "Image 2":
|
24 |
-
# Test the model with Image 2
|
25 |
-
st.write("Testing the model with Image 2...")
|
26 |
-
elif image_option == "Image 3":
|
27 |
-
# Test the model with Image 3
|
28 |
-
st.write("Testing the model with Image 3...")
|
29 |
-
elif uploaded_file is not None:
|
30 |
-
# Test the model with the uploaded image
|
31 |
-
st.write("Testing the model with the uploaded image...")
|
32 |
-
else:
|
33 |
-
st.write("Please select or upload an image.")
|
34 |
|
35 |
# encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")
|
36 |
|
|
|
1 |
import streamlit as st
|
2 |
+
# import torch
|
3 |
# from transformers import AutoProcessor, UdopForConditionalGeneration
|
4 |
# from datasets import load_dataset
|
5 |
|
6 |
# processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True)
|
7 |
# model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
|
8 |
|
9 |
+
st.title("Document (/Image) Selection and Upload")
|
10 |
+
st.write("Select or upload a document (/an image) to test the model.")
|
11 |
|
12 |
+
# Image selection
|
13 |
+
uploaded_files = st.file_uploader("Upload document(s) [/image(s)]:", type=["docx", "pdf", "jpg", "jpeg", "png"], accept_multiple_files=True)
|
14 |
+
selected_file = st.selectbox("Select a document (/an image):", uploaded_files, format_func=lambda file: file.name if file else "None")
|
15 |
|
16 |
+
# Display selected image
|
17 |
+
if selected_file is not None and selected_file != "None":
|
18 |
+
st.image(selected_file, caption="Selected Image")
|
|
|
19 |
|
20 |
# Model testing button
|
21 |
+
if st.button("Test Model") and selected_file != "None":
|
22 |
+
st.write("Testing the model with the selected image...")
|
23 |
+
elif st.button("Test Model") and selected_file == "None":
|
24 |
+
st.write("Please upload and select an image.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")
|
27 |
|