unknown
commited on
Commit
Β·
fffc505
1
Parent(s):
dd4319f
switched to two columns interface
Browse files
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",
|
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 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
|
|
68 |
with st.spinner("Generating answer..."):
|
69 |
answer = generate_answer(model, processor, image, question)
|
70 |
-
st.success(
|
71 |
-
|
72 |
-
|
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()
|