Spaces:
Running
on
T4
Running
on
T4
rerank model
Browse files- pages/Semantic_Search.py +36 -38
pages/Semantic_Search.py
CHANGED
@@ -674,47 +674,45 @@ if(search_all_type == True or 1==1):
|
|
674 |
|
675 |
|
676 |
def write_user_message(md,ans):
|
677 |
-
ans
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
st.
|
|
|
|
|
694 |
|
695 |
-
|
696 |
-
|
697 |
-
st.markdown("<div style='fontSize:15px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'>Input Image: </div>", unsafe_allow_html = True)
|
698 |
-
|
699 |
-
if(st.session_state.input_imageUpload == 'yes'):
|
700 |
-
|
701 |
-
if(st.session_state.input_rad_1 is not None and st.session_state.input_rad_1!=""):
|
702 |
-
num_str = str(int(st.session_state.input_rad_1.strip())-1)
|
703 |
-
img_file = parent_dirname+"/gen_images/"+st.session_state.image_prompt+"_gen_"+num_str+"-resized_display.jpg"
|
704 |
-
else:
|
705 |
-
img_file = parent_dirname+"/uploaded_images/"+st.session_state.img_doc.name.split(".")[0]+"-resized_display."+st.session_state.img_doc.name.split(".")[1]
|
706 |
|
707 |
-
st.
|
708 |
-
if(st.session_state.input_rekog_label !=""):
|
709 |
-
with st.expander("Enriched Query Metadata:"):
|
710 |
-
st.markdown('<p>'+json.dumps(st.session_state.input_rekog_directoutput)+'<p>',unsafe_allow_html=True)
|
711 |
-
else:
|
712 |
-
st.markdown("<div style='fontSize:15px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'>None</div>", unsafe_allow_html = True)
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
|
717 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
|
719 |
|
720 |
# def stem_(sentence):
|
|
|
674 |
|
675 |
|
676 |
def write_user_message(md,ans):
|
677 |
+
if(len(ans["answer"])>0)
|
678 |
+
ans = ans["answer"][0]
|
679 |
+
col1, col2, col3 = st.columns([3,40,20])
|
680 |
+
|
681 |
+
with col1:
|
682 |
+
st.image(USER_ICON, use_column_width='always')
|
683 |
+
with col2:
|
684 |
+
st.markdown("<div style='fontSize:15px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'>Input Text: </div><div style='fontSize:25px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;font-style: italic;color:#e28743'>"+md['question']+"</div>", unsafe_allow_html = True)
|
685 |
+
if('query_sparse' in ans):
|
686 |
+
with st.expander("Expanded Query:"):
|
687 |
+
query_sparse = dict(sorted(ans['query_sparse'].items(), key=lambda item: item[1],reverse=True))
|
688 |
+
filtered_query_sparse = dict()
|
689 |
+
for key in query_sparse:
|
690 |
+
filtered_query_sparse[key] = round(query_sparse[key], 2)
|
691 |
+
st.write(filtered_query_sparse)
|
692 |
+
if(st.session_state.input_is_rewrite_query == "enabled" and st.session_state.input_rewritten_query !=""):
|
693 |
+
with st.expander("Re-written Query:"):
|
694 |
+
st.json(st.session_state.input_rewritten_query,expanded = True)
|
695 |
+
|
696 |
|
697 |
+
with col3:
|
698 |
+
st.markdown("<div style='fontSize:15px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'>Input Image: </div>", unsafe_allow_html = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
699 |
|
700 |
+
if(st.session_state.input_imageUpload == 'yes'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
701 |
|
702 |
+
if(st.session_state.input_rad_1 is not None and st.session_state.input_rad_1!=""):
|
703 |
+
num_str = str(int(st.session_state.input_rad_1.strip())-1)
|
704 |
+
img_file = parent_dirname+"/gen_images/"+st.session_state.image_prompt+"_gen_"+num_str+"-resized_display.jpg"
|
705 |
+
else:
|
706 |
+
img_file = parent_dirname+"/uploaded_images/"+st.session_state.img_doc.name.split(".")[0]+"-resized_display."+st.session_state.img_doc.name.split(".")[1]
|
707 |
+
|
708 |
+
st.image(img_file)
|
709 |
+
if(st.session_state.input_rekog_label !=""):
|
710 |
+
with st.expander("Enriched Query Metadata:"):
|
711 |
+
st.markdown('<p>'+json.dumps(st.session_state.input_rekog_directoutput)+'<p>',unsafe_allow_html=True)
|
712 |
+
else:
|
713 |
+
st.markdown("<div style='fontSize:15px;padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'>None</div>", unsafe_allow_html = True)
|
714 |
+
|
715 |
+
st.markdown('---')
|
716 |
|
717 |
|
718 |
# def stem_(sentence):
|