Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,40 @@ from datasets import load_dataset
|
|
5 |
processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True)
|
6 |
model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")
|
9 |
|
10 |
# predicted_ids = model.generate(**encoding)
|
|
|
5 |
processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True)
|
6 |
model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
|
7 |
|
8 |
+
st.title("Image Selection and Upload")
|
9 |
+
st.write("Select or upload an image to test the model.")
|
10 |
+
|
11 |
+
# Image selection
|
12 |
+
image_option = st.selectbox("Select an image:", ("Image 1", "Image 2", "Image 3"))
|
13 |
+
if image_option == "Image 1":
|
14 |
+
st.image("image1.jpg", caption="Image 1")
|
15 |
+
elif image_option == "Image 2":
|
16 |
+
st.image("image2.jpg", caption="Image 2")
|
17 |
+
elif image_option == "Image 3":
|
18 |
+
st.image("image3.jpg", caption="Image 3")
|
19 |
+
|
20 |
+
# Image upload
|
21 |
+
uploaded_file = st.file_uploader("Upload an image:", type=["jpg", "jpeg", "png"])
|
22 |
+
if uploaded_file is not None:
|
23 |
+
st.image(uploaded_file, caption="Uploaded Image")
|
24 |
+
|
25 |
+
# Model testing button
|
26 |
+
if st.button("Test Model"):
|
27 |
+
if image_option == "Image 1":
|
28 |
+
# Test the model with Image 1
|
29 |
+
st.write("Testing the model with Image 1...")
|
30 |
+
elif image_option == "Image 2":
|
31 |
+
# Test the model with Image 2
|
32 |
+
st.write("Testing the model with Image 2...")
|
33 |
+
elif image_option == "Image 3":
|
34 |
+
# Test the model with Image 3
|
35 |
+
st.write("Testing the model with Image 3...")
|
36 |
+
elif uploaded_file is not None:
|
37 |
+
# Test the model with the uploaded image
|
38 |
+
st.write("Testing the model with the uploaded image...")
|
39 |
+
else:
|
40 |
+
st.write("Please select or upload an image.")
|
41 |
+
|
42 |
# encoding = processor(image, question, words, boxes=boxes, return_tensors="pt")
|
43 |
|
44 |
# predicted_ids = model.generate(**encoding)
|