kh-CHEUNG commited on
Commit
092ff29
·
verified ·
1 Parent(s): 174c617

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -22
app.py CHANGED
@@ -1,36 +1,27 @@
1
  import streamlit as st
2
- # import transformers
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
- # Image upload
14
- uploaded_file = st.file_uploader("Upload an image:", type=["jpg", "jpeg", "png"])
15
- if uploaded_file is not None:
16
- st.image(uploaded_file, caption="Uploaded Image")
17
 
18
  # Model testing button
19
- if st.button("Test Model"):
20
- if image_option == "Image 1":
21
- # Test the model with Image 1
22
- st.write("Testing the model with Image 1...")
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