kh-CHEUNG commited on
Commit
713e43d
1 Parent(s): c799276

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -42,15 +42,15 @@ processor = AutoProcessor.from_pretrained("microsoft/udop-large", apply_ocr=True
42
  model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
43
 
44
  st.title("GenAI Demo (by ITT)")
45
- st.write("Upload and Select a document (/an image) to test the model.")
46
 
47
  #2 column layout
48
  col1, col2 = st.columns(2)
49
 
50
  with col1:
51
  # File selection
52
- uploaded_files = st.file_uploader("Upload document(s) [/image(s)]:", type=["docx", "pdf", "pptx", "jpg", "jpeg", "png"], accept_multiple_files=True)
53
- selected_file = st.selectbox("Select a document (/an image):", uploaded_files, format_func=lambda file: file.name if file else "None")
54
 
55
  # Display selected file
56
  if selected_file is not None and selected_file != "None":
@@ -66,15 +66,15 @@ with col2:
66
  ## Question (/Prompt)
67
  # question = "Question answering. How many unsafe practice of Lifting Operation?"
68
  default_question = "Is this a Lifting Operation scene?"
69
- task_type = st.selectbox("Question Type:", ("Classification", "Question Answering", "Layout Analysis"))
70
- question_text = st.text_area("Prompt:", placeholder=default_question)
71
  if question_text is not None:
72
  question = task_type + ". " + question_text
73
  else:
74
  question = task_type + ". " + default_question
75
 
76
  ## Test button
77
- testButton = st.button("Test Model")
78
 
79
  ## Perform Model Testing when Image is uploaded and selected as well as Test button is pressed
80
  if testButton and selected_file != "None":
 
42
  model = UdopForConditionalGeneration.from_pretrained("microsoft/udop-large")
43
 
44
  st.title("GenAI Demo (by ITT)")
45
+ st.text("Upload and Select a document (/an image) to test the model.")
46
 
47
  #2 column layout
48
  col1, col2 = st.columns(2)
49
 
50
  with col1:
51
  # File selection
52
+ uploaded_files = st.file_uploader("Upload document(s) [/image(s)]:", type=["docx", "pdf", "pptx", "jpg", "jpeg", "png"], accept_multiple_files=True, , key="fileUpload")
53
+ selected_file = st.selectbox("Select a document (/an image):", uploaded_files, format_func=lambda file: file.name if file else "None", key="fileSelect")
54
 
55
  # Display selected file
56
  if selected_file is not None and selected_file != "None":
 
66
  ## Question (/Prompt)
67
  # question = "Question answering. How many unsafe practice of Lifting Operation?"
68
  default_question = "Is this a Lifting Operation scene?"
69
+ task_type = st.selectbox("Question Type:", ("Classification", "Question Answering", "Layout Analysis"), index=1, key="taskSelect")
70
+ question_text = st.text_area("Prompt:", placeholder=default_question, key="questionInput")
71
  if question_text is not None:
72
  question = task_type + ". " + question_text
73
  else:
74
  question = task_type + ". " + default_question
75
 
76
  ## Test button
77
+ testButton = st.button("Test Model", key="testStart")
78
 
79
  ## Perform Model Testing when Image is uploaded and selected as well as Test button is pressed
80
  if testButton and selected_file != "None":