unknown commited on
Commit
fffc505
Β·
1 Parent(s): dd4319f

switched to two columns interface

Browse files
Files changed (1) hide show
  1. app.py +18 -21
app.py CHANGED
@@ -29,18 +29,9 @@ def generate_answer(model, processor, image, prompt):
29
  parsed_answer = processor.post_process_generation(generated_text, task=task, image_size=(image.width, image.height))
30
  return parsed_answer[task]
31
 
32
- # Function to display config without nested expanders
33
- def display_config(config, depth=0):
34
- for key, value in config.items():
35
- if isinstance(value, dict):
36
- st.markdown(f"{' ' * depth}**{key}**:")
37
- display_config(value, depth + 1)
38
- else:
39
- st.markdown(f"{' ' * depth}{key}: {value}")
40
-
41
  # Streamlit app
42
  def main():
43
- st.set_page_config(page_title="Lutece-Vision-Base Demo", page_icon="πŸ—Ό", layout="wide", initial_sidebar_state="expanded")
44
 
45
  # Title and description
46
  st.title("πŸ—Ό Lutece-Vision-Base Demo")
@@ -59,20 +50,26 @@ def main():
59
 
60
  if uploaded_file is not None:
61
  image = Image.open(uploaded_file).convert('RGB')
62
- st.image(image, caption="Uploaded Document", use_column_width=True)
63
-
64
- # Question input
65
- question = st.text_input("❓ Ask a question about the document", "")
 
 
 
 
 
 
 
 
66
 
67
- if st.button("πŸ” Generate Answer"):
 
68
  with st.spinner("Generating answer..."):
69
  answer = generate_answer(model, processor, image, question)
70
- st.success(f"## πŸ’‘ {answer}")
71
-
72
- # # Model configuration viewer
73
- # with st.expander("πŸ”§ Model Configuration"):
74
- # config_dict = model.config.to_dict()
75
- # display_config(config_dict)
76
 
77
  if __name__ == "__main__":
78
  main()
 
29
  parsed_answer = processor.post_process_generation(generated_text, task=task, image_size=(image.width, image.height))
30
  return parsed_answer[task]
31
 
 
 
 
 
 
 
 
 
 
32
  # Streamlit app
33
  def main():
34
+ st.set_page_config(page_title="Lutece-Vision-Base Demo", page_icon="πŸ—Ό", layout="wide", initial_sidebar_state="expanded")
35
 
36
  # Title and description
37
  st.title("πŸ—Ό Lutece-Vision-Base Demo")
 
50
 
51
  if uploaded_file is not None:
52
  image = Image.open(uploaded_file).convert('RGB')
53
+
54
+ # Two-column layout
55
+ col1, col2 = st.columns(2)
56
+
57
+ with col1:
58
+ # Display image with controlled size
59
+ st.image(image, caption="Uploaded Document", use_column_width=True)
60
+
61
+ with col2:
62
+ # Question input
63
+ question = st.text_input("❓ Ask a question about the document", "")
64
+ submit_button = st.button("πŸ” Generate Answer")
65
 
66
+ # Answer section spanning both columns
67
+ if submit_button and question:
68
  with st.spinner("Generating answer..."):
69
  answer = generate_answer(model, processor, image, question)
70
+ st.success("Answer generated!")
71
+ st.markdown(f"## πŸ’‘ Answer")
72
+ st.markdown(answer)
 
 
 
73
 
74
  if __name__ == "__main__":
75
  main()