prasadnu commited on
Commit
34af0a6
·
1 Parent(s): a4942cf

rerank model

Browse files
pages/Multimodal_Conversational_Search.py CHANGED
@@ -200,86 +200,86 @@ def write_user_message(placeholder,md):
200
 
201
  def render_answer(placeholder,question,answer,index,res_img):
202
 
203
-
204
- col1, col2, col_3 = st.columns([4,74,22])
205
- with col1:
206
- st.image(AI_ICON, use_column_width='always')
207
- with col2:
208
- ans_ = answer['answer']
209
- st.write(ans_)
210
-
211
- # polly_response = polly_client.synthesize_speech(VoiceId='Joanna',
212
- # OutputFormat='ogg_vorbis',
213
- # Text = ans_,
214
- # Engine = 'neural')
215
-
216
- # audio_col1, audio_col2 = st.columns([50,50])
217
- # with audio_col1:
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:
233
- @st.cache_data
234
- def load_table_from_file(filepath):
235
- df = pd.read_csv(filepath, skipinitialspace=True, on_bad_lines='skip', delimiter='`')
236
- df.fillna(method='pad', inplace=True)
237
- return df
238
-
239
- with st.expander("Relevant Sources:"):
240
- with st.container():
241
- if(len(res_img)>0):
242
- #with st.expander("Images:"):
243
-
244
- idx = 0
245
- print(res_img)
246
- for i in range(0,len(res_img)):
247
-
248
- if(st.session_state.input_is_colpali):
249
- if(st.session_state.show_columns == True):
250
- cols_per_row = 3
251
- st.session_state.image_placeholder=st.empty()
252
- with st.session_state.image_placeholder.container():
253
- row = st.columns(cols_per_row)
254
- for j, item in enumerate(res_img[i:i+cols_per_row]):
255
- with row[j]:
256
- st.image(item['file'])
257
-
258
- else:
259
- st.session_state.image_placeholder = st.empty()
260
- with st.session_state.image_placeholder.container():
261
- col3_,col4_,col5_ = st.columns([33,33,33])
262
- with col3_:
263
- st.image(res_img[i]['file'])
264
- else:
265
- if(res_img[i]['file'].lower()!='none' and idx < 1):
266
- col3,col4,col5 = st.columns([33,33,33])
267
- cols = [col3,col4]
268
- img = res_img[i]['file'].split(".")[0]
269
- caption = res_img[i]['caption']
270
 
271
- with cols[idx]:
 
 
 
 
 
 
 
 
 
 
 
 
272
 
273
- st.image(parent_dirname+"/figures/"+st.session_state.input_index+"/"+img+".jpg")
274
- idx = idx+1
275
- if(st.session_state.show_columns == True):
276
- st.session_state.show_columns = False
277
- if(len(answer["table"] )>0):
278
- #with st.expander("Table:"):
279
- df = load_table_from_file(answer["table"][0]['name'])
280
- st.table(df)
281
- #with st.expander("Raw sources:"):
282
- st.write(answer["source"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
 
284
 
285
  # with col_3:
 
200
 
201
  def render_answer(placeholder,question,answer,index,res_img):
202
 
203
+ with placeholder.container():
204
+ col1, col2, col_3 = st.columns([4,74,22])
205
+ with col1:
206
+ st.image(AI_ICON, use_column_width='always')
207
+ with col2:
208
+ ans_ = answer['answer']
209
+ st.write(ans_)
210
+
211
+ # polly_response = polly_client.synthesize_speech(VoiceId='Joanna',
212
+ # OutputFormat='ogg_vorbis',
213
+ # Text = ans_,
214
+ # Engine = 'neural')
215
+
216
+ # audio_col1, audio_col2 = st.columns([50,50])
217
+ # with audio_col1:
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:
233
+ @st.cache_data
234
+ def load_table_from_file(filepath):
235
+ df = pd.read_csv(filepath, skipinitialspace=True, on_bad_lines='skip', delimiter='`')
236
+ df.fillna(method='pad', inplace=True)
237
+ return df
238
+
239
+ with st.expander("Relevant Sources:"):
240
+ with st.container():
241
+ if(len(res_img)>0):
242
+ #with st.expander("Images:"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ idx = 0
245
+ print(res_img)
246
+ for i in range(0,len(res_img)):
247
+
248
+ if(st.session_state.input_is_colpali):
249
+ if(st.session_state.show_columns == True):
250
+ cols_per_row = 3
251
+ st.session_state.image_placeholder=st.empty()
252
+ with st.session_state.image_placeholder.container():
253
+ row = st.columns(cols_per_row)
254
+ for j, item in enumerate(res_img[i:i+cols_per_row]):
255
+ with row[j]:
256
+ st.image(item['file'])
257
 
258
+ else:
259
+ st.session_state.image_placeholder = st.empty()
260
+ with st.session_state.image_placeholder.container():
261
+ col3_,col4_,col5_ = st.columns([33,33,33])
262
+ with col3_:
263
+ st.image(res_img[i]['file'])
264
+ else:
265
+ if(res_img[i]['file'].lower()!='none' and idx < 1):
266
+ col3,col4,col5 = st.columns([33,33,33])
267
+ cols = [col3,col4]
268
+ img = res_img[i]['file'].split(".")[0]
269
+ caption = res_img[i]['caption']
270
+
271
+ with cols[idx]:
272
+
273
+ st.image(parent_dirname+"/figures/"+st.session_state.input_index+"/"+img+".jpg")
274
+ idx = idx+1
275
+ if(st.session_state.show_columns == True):
276
+ st.session_state.show_columns = False
277
+ if(len(answer["table"] )>0):
278
+ #with st.expander("Table:"):
279
+ df = load_table_from_file(answer["table"][0]['name'])
280
+ st.table(df)
281
+ #with st.expander("Raw sources:"):
282
+ st.write(answer["source"])
283
 
284
 
285
  # with col_3: