Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
rerank model
Browse files
pages/Multimodal_Conversational_Search.py
CHANGED
|
@@ -195,10 +195,10 @@ def write_user_message(placeholder,md):
|
|
| 195 |
#st.warning(md['question'])
|
| 196 |
|
| 197 |
st.markdown("<div style='color:#e28743';font-size:18px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;font-style: italic;'>"+md['question']+"</div>", unsafe_allow_html = True)
|
| 198 |
-
|
| 199 |
|
| 200 |
|
| 201 |
-
def render_answer(question,answer,index,res_img):
|
| 202 |
|
| 203 |
|
| 204 |
col1, col2, col_3 = st.columns([4,74,22])
|
|
@@ -218,15 +218,15 @@ def render_answer(question,answer,index,res_img):
|
|
| 218 |
# st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
|
| 219 |
rdn_key_1 = ''.join([random.choice(string.ascii_letters)
|
| 220 |
for _ in range(10)])
|
| 221 |
-
def show_maxsim():
|
| 222 |
st.session_state.show_columns = True
|
| 223 |
st.session_state.maxSimImages = colpali.img_highlight(st.session_state.top_img, st.session_state.query_token_vectors, st.session_state.query_tokens)
|
| 224 |
handle_input()
|
| 225 |
-
placeholder = st.empty()
|
| 226 |
-
with placeholder.container():
|
| 227 |
-
|
| 228 |
if(st.session_state.input_is_colpali):
|
| 229 |
-
st.button("Show similarity map",key=rdn_key_1,on_click = show_maxsim)
|
| 230 |
|
| 231 |
colu1,colu2,colu3 = st.columns([4,82,20])
|
| 232 |
with colu2:
|
|
@@ -310,22 +310,20 @@ def render_answer(question,answer,index,res_img):
|
|
| 310 |
|
| 311 |
|
| 312 |
#Each answer will have context of the question asked in order to associate the provided feedback with the respective question
|
| 313 |
-
def write_chat_message(md, q,index):
|
| 314 |
if(st.session_state.show_columns):
|
| 315 |
res_img = st.session_state.maxSimImages
|
| 316 |
else:
|
| 317 |
res_img = md['image']
|
| 318 |
-
|
| 319 |
-
with chat:
|
| 320 |
-
render_answer(q,md,index,res_img)
|
| 321 |
|
| 322 |
def render_all(placeholder):
|
| 323 |
index = 0
|
| 324 |
for (q, a) in zip(st.session_state.questions_, st.session_state.answers_):
|
| 325 |
index = index +1
|
| 326 |
|
| 327 |
-
write_user_message(placeholder,q)
|
| 328 |
-
write_chat_message(a, q,index)
|
| 329 |
|
| 330 |
placeholder = st.empty()
|
| 331 |
render_all(placeholder)
|
|
|
|
| 195 |
#st.warning(md['question'])
|
| 196 |
|
| 197 |
st.markdown("<div style='color:#e28743';font-size:18px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;font-style: italic;'>"+md['question']+"</div>", unsafe_allow_html = True)
|
| 198 |
+
return placeholder
|
| 199 |
|
| 200 |
|
| 201 |
+
def render_answer(placeholder,question,answer,index,res_img):
|
| 202 |
|
| 203 |
|
| 204 |
col1, col2, col_3 = st.columns([4,74,22])
|
|
|
|
| 218 |
# st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
|
| 219 |
rdn_key_1 = ''.join([random.choice(string.ascii_letters)
|
| 220 |
for _ in range(10)])
|
| 221 |
+
def show_maxsim(placeholder,dummy):
|
| 222 |
st.session_state.show_columns = True
|
| 223 |
st.session_state.maxSimImages = colpali.img_highlight(st.session_state.top_img, st.session_state.query_token_vectors, st.session_state.query_tokens)
|
| 224 |
handle_input()
|
| 225 |
+
# placeholder = st.empty()
|
| 226 |
+
# with placeholder.container():
|
| 227 |
+
render_all(placeholder)
|
| 228 |
if(st.session_state.input_is_colpali):
|
| 229 |
+
st.button("Show similarity map",key=rdn_key_1,on_click = show_maxsim,args=(placeholder,"default_img"))
|
| 230 |
|
| 231 |
colu1,colu2,colu3 = st.columns([4,82,20])
|
| 232 |
with colu2:
|
|
|
|
| 310 |
|
| 311 |
|
| 312 |
#Each answer will have context of the question asked in order to associate the provided feedback with the respective question
|
| 313 |
+
def write_chat_message(placeholder, md, q,index):
|
| 314 |
if(st.session_state.show_columns):
|
| 315 |
res_img = st.session_state.maxSimImages
|
| 316 |
else:
|
| 317 |
res_img = md['image']
|
| 318 |
+
render_answer(placeholder,q,md,index,res_img)
|
|
|
|
|
|
|
| 319 |
|
| 320 |
def render_all(placeholder):
|
| 321 |
index = 0
|
| 322 |
for (q, a) in zip(st.session_state.questions_, st.session_state.answers_):
|
| 323 |
index = index +1
|
| 324 |
|
| 325 |
+
placeholder = write_user_message(placeholder,q)
|
| 326 |
+
write_chat_message(placeholder, a, q,index)
|
| 327 |
|
| 328 |
placeholder = st.empty()
|
| 329 |
render_all(placeholder)
|