Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ prompt = PromptTemplate(
|
|
| 22 |
#Response: {elements}
|
| 23 |
\n\n
|
| 24 |
Your structured response:""",
|
| 25 |
-
|
| 26 |
|
| 27 |
def process_query(image, query):
|
| 28 |
encoding = processor(image, query, return_tensors="pt")
|
|
@@ -34,22 +34,43 @@ def process_query(image, query):
|
|
| 34 |
return response
|
| 35 |
|
| 36 |
st.set_page_config(page_title="Insightly")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def main():
|
| 39 |
st.title("Chat With Images ๐ผ๏ธ")
|
| 40 |
|
| 41 |
-
# Add a link in the sidebar
|
| 42 |
-
st.sidebar.markdown("<p class='sidebar-link'>๐ <a href='https://insightly-csv-bot.hf.space/'> CSV Bot</a></p>", unsafe_allow_html=True)
|
| 43 |
-
st.sidebar.markdown("<p class='sidebar-link'>๐ <a href='https://chandrakalagowda-demo2.hf.space/'> PDF Bot </a></p>", unsafe_allow_html=True)
|
| 44 |
-
st.sidebar.markdown("<p class='sidebar-link'>๐ผ๏ธ <a href='https://insightly-image-reader.hf.space'> Frame Capturer</a></p>", unsafe_allow_html=True)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
uploaded_file = st.file_uploader('Upload your Image', type=['png', 'jpeg', 'jpg'])
|
| 48 |
|
| 49 |
if uploaded_file is not None:
|
|
|
|
| 50 |
image = Image.open(uploaded_file)
|
| 51 |
st.image(image, caption='Uploaded Image.', width=300)
|
| 52 |
-
|
| 53 |
cancel_button = st.button('Remove this image')
|
| 54 |
if cancel_button:
|
| 55 |
st.markdown(
|
|
@@ -63,16 +84,15 @@ def main():
|
|
| 63 |
</style>""",
|
| 64 |
unsafe_allow_html=True
|
| 65 |
)
|
| 66 |
-
|
| 67 |
query = st.text_input('Type your question here')
|
| 68 |
|
| 69 |
if query:
|
| 70 |
with st.spinner('Processing...'):
|
| 71 |
answer = process_query(image, query)
|
| 72 |
st.write(answer)
|
| 73 |
-
|
| 74 |
if cancel_button:
|
| 75 |
st.stop()
|
| 76 |
-
|
| 77 |
if __name__ == "__main__":
|
| 78 |
main()
|
|
|
|
| 22 |
#Response: {elements}
|
| 23 |
\n\n
|
| 24 |
Your structured response:""",
|
| 25 |
+
)
|
| 26 |
|
| 27 |
def process_query(image, query):
|
| 28 |
encoding = processor(image, query, return_tensors="pt")
|
|
|
|
| 34 |
return response
|
| 35 |
|
| 36 |
st.set_page_config(page_title="Insightly")
|
| 37 |
+
# Sidebar contents
|
| 38 |
+
with st.sidebar:
|
| 39 |
+
st.sidebar.image("https://i.ibb.co/bX6GdqG/insightly-wbg.png", use_column_width=True)
|
| 40 |
+
st.sidebar.markdown("<p class='sidebar-link'>๐ <a href='https://insightly-csv-bot.hf.space/'>Insightly - CSV Bot</a></p>", unsafe_allow_html=True)
|
| 41 |
+
st.sidebar.markdown("<div class='vertical-space'></div>", unsafe_allow_html=True)
|
| 42 |
+
|
| 43 |
+
# Custom CSS to style the link and create vertical space
|
| 44 |
+
st.markdown(
|
| 45 |
+
"""
|
| 46 |
+
<style>
|
| 47 |
+
.image-container {
|
| 48 |
+
margin-bottom: 60px;
|
| 49 |
+
}
|
| 50 |
+
.sidebar-link {
|
| 51 |
+
display: flex;
|
| 52 |
+
justify-content: center;
|
| 53 |
+
font-size: 24px;
|
| 54 |
+
margin-top: 20px;
|
| 55 |
+
}
|
| 56 |
+
.vertical-space {
|
| 57 |
+
height: 20px;
|
| 58 |
+
}
|
| 59 |
+
</style>
|
| 60 |
+
""",
|
| 61 |
+
unsafe_allow_html=True,
|
| 62 |
+
)
|
| 63 |
|
| 64 |
def main():
|
| 65 |
st.title("Chat With Images ๐ผ๏ธ")
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
uploaded_file = st.file_uploader('Upload your Image', type=['png', 'jpeg', 'jpg'])
|
| 68 |
|
| 69 |
if uploaded_file is not None:
|
| 70 |
+
|
| 71 |
image = Image.open(uploaded_file)
|
| 72 |
st.image(image, caption='Uploaded Image.', width=300)
|
| 73 |
+
|
| 74 |
cancel_button = st.button('Remove this image')
|
| 75 |
if cancel_button:
|
| 76 |
st.markdown(
|
|
|
|
| 84 |
</style>""",
|
| 85 |
unsafe_allow_html=True
|
| 86 |
)
|
|
|
|
| 87 |
query = st.text_input('Type your question here')
|
| 88 |
|
| 89 |
if query:
|
| 90 |
with st.spinner('Processing...'):
|
| 91 |
answer = process_query(image, query)
|
| 92 |
st.write(answer)
|
| 93 |
+
|
| 94 |
if cancel_button:
|
| 95 |
st.stop()
|
| 96 |
+
|
| 97 |
if __name__ == "__main__":
|
| 98 |
main()
|