Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
rerank model
Browse files
pages/Multimodal_Conversational_Search.py
CHANGED
|
@@ -345,55 +345,55 @@ def render_answer(question,answer,index,res_img):
|
|
| 345 |
with st.expander("Relevant Sources:"):
|
| 346 |
with st.container():
|
| 347 |
if(len(res_img)>0):
|
| 348 |
-
with st.expander("Images:"):
|
| 349 |
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
else:
|
| 365 |
-
st.session_state.image_placeholder = st.empty()
|
| 366 |
-
with st.session_state.image_placeholder.container():
|
| 367 |
-
col3_,col4_,col5_ = st.columns([33,33,33])
|
| 368 |
-
with col3_:
|
| 369 |
-
st.image(res_img[i]['file'])
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
|
| 375 |
else:
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
#st.markdown("<div style='color:#e28743';padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'><b>Sources from the document:</b></div>", unsafe_allow_html = True)
|
| 390 |
if(len(answer["table"] )>0):
|
| 391 |
-
with st.expander("Table:"):
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
with st.expander("Raw sources:"):
|
| 396 |
-
|
| 397 |
|
| 398 |
|
| 399 |
|
|
|
|
| 345 |
with st.expander("Relevant Sources:"):
|
| 346 |
with st.container():
|
| 347 |
if(len(res_img)>0):
|
| 348 |
+
#with st.expander("Images:"):
|
| 349 |
|
| 350 |
+
idx = 0
|
| 351 |
+
print(res_img)
|
| 352 |
+
for i in range(0,len(res_img)):
|
| 353 |
+
|
| 354 |
+
if(st.session_state.input_is_colpali):
|
| 355 |
+
if(st.session_state.show_columns == True):
|
| 356 |
+
cols_per_row = 3
|
| 357 |
+
st.session_state.image_placeholder=st.empty()
|
| 358 |
+
with st.session_state.image_placeholder.container():
|
| 359 |
+
row = st.columns(cols_per_row)
|
| 360 |
+
for j, item in enumerate(res_img[i:i+cols_per_row]):
|
| 361 |
+
with row[j]:
|
| 362 |
+
st.image(item['file'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
|
| 364 |
else:
|
| 365 |
+
st.session_state.image_placeholder = st.empty()
|
| 366 |
+
with st.session_state.image_placeholder.container():
|
| 367 |
+
col3_,col4_,col5_ = st.columns([33,33,33])
|
| 368 |
+
with col3_:
|
| 369 |
+
st.image(res_img[i]['file'])
|
| 370 |
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
else:
|
| 376 |
+
if(res_img[i]['file'].lower()!='none' and idx < 2):
|
| 377 |
+
col3,col4,col5 = st.columns([33,33,33])
|
| 378 |
+
cols = [col3,col4]
|
| 379 |
+
img = res_img[i]['file'].split(".")[0]
|
| 380 |
+
caption = res_img[i]['caption']
|
| 381 |
+
|
| 382 |
+
with cols[idx]:
|
| 383 |
+
|
| 384 |
+
st.image(parent_dirname+"/figures/"+st.session_state.input_index+"/"+img+".jpg")
|
| 385 |
+
#st.write(caption)
|
| 386 |
+
idx = idx+1
|
| 387 |
+
if(st.session_state.show_columns == True):
|
| 388 |
+
st.session_state.show_columns = False
|
| 389 |
#st.markdown("<div style='color:#e28743';padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'><b>Sources from the document:</b></div>", unsafe_allow_html = True)
|
| 390 |
if(len(answer["table"] )>0):
|
| 391 |
+
#with st.expander("Table:"):
|
| 392 |
+
df = pd.read_csv(answer["table"][0]['name'],skipinitialspace = True, on_bad_lines='skip',delimiter='`')
|
| 393 |
+
df.fillna(method='pad', inplace=True)
|
| 394 |
+
st.table(df)
|
| 395 |
+
#with st.expander("Raw sources:"):
|
| 396 |
+
st.write(answer["source"])
|
| 397 |
|
| 398 |
|
| 399 |
|