Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
colpali fix
Browse files- RAG/colpali.py +0 -6
RAG/colpali.py
CHANGED
|
@@ -75,7 +75,6 @@ if 'query_tokens' not in st.session_state:
|
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
-
@st.cache_resource
|
| 79 |
def call_nova(
|
| 80 |
model,
|
| 81 |
messages,
|
|
@@ -119,14 +118,12 @@ def call_nova(
|
|
| 119 |
modelId=model, body=json.dumps(request_body)
|
| 120 |
)
|
| 121 |
return response["body"]
|
| 122 |
-
@st.cache_resource
|
| 123 |
def get_base64_encoded_value(media_path):
|
| 124 |
with open(media_path, "rb") as media_file:
|
| 125 |
binary_data = media_file.read()
|
| 126 |
base_64_encoded_data = base64.b64encode(binary_data)
|
| 127 |
base64_string = base_64_encoded_data.decode("utf-8")
|
| 128 |
return base64_string
|
| 129 |
-
@st.cache_resource
|
| 130 |
def generate_ans(top_result,query):
|
| 131 |
print(query)
|
| 132 |
system_message = "given an image of a PDF page, answer the question. Be accurate to the question. If you don't find the answer in the page, please say, I don't know"
|
|
@@ -156,7 +153,6 @@ def generate_ans(top_result,query):
|
|
| 156 |
print(content_text)
|
| 157 |
return content_text
|
| 158 |
|
| 159 |
-
@st.cache_resource
|
| 160 |
def img_highlight(img,batch_queries,query_tokens):
|
| 161 |
# Reference from : https://github.com/tonywu71/colpali-cookbooks/blob/main/examples/gen_colpali_similarity_maps.ipynb
|
| 162 |
with open(img, "rb") as f:
|
|
@@ -249,8 +245,6 @@ def img_highlight(img,batch_queries,query_tokens):
|
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
-
|
| 253 |
-
@st.cache_resource
|
| 254 |
def colpali_search_rerank(query):
|
| 255 |
if(st.session_state.show_columns == True):
|
| 256 |
print("show columns activated------------------------")
|
|
|
|
| 75 |
|
| 76 |
|
| 77 |
|
|
|
|
| 78 |
def call_nova(
|
| 79 |
model,
|
| 80 |
messages,
|
|
|
|
| 118 |
modelId=model, body=json.dumps(request_body)
|
| 119 |
)
|
| 120 |
return response["body"]
|
|
|
|
| 121 |
def get_base64_encoded_value(media_path):
|
| 122 |
with open(media_path, "rb") as media_file:
|
| 123 |
binary_data = media_file.read()
|
| 124 |
base_64_encoded_data = base64.b64encode(binary_data)
|
| 125 |
base64_string = base_64_encoded_data.decode("utf-8")
|
| 126 |
return base64_string
|
|
|
|
| 127 |
def generate_ans(top_result,query):
|
| 128 |
print(query)
|
| 129 |
system_message = "given an image of a PDF page, answer the question. Be accurate to the question. If you don't find the answer in the page, please say, I don't know"
|
|
|
|
| 153 |
print(content_text)
|
| 154 |
return content_text
|
| 155 |
|
|
|
|
| 156 |
def img_highlight(img,batch_queries,query_tokens):
|
| 157 |
# Reference from : https://github.com/tonywu71/colpali-cookbooks/blob/main/examples/gen_colpali_similarity_maps.ipynb
|
| 158 |
with open(img, "rb") as f:
|
|
|
|
| 245 |
|
| 246 |
|
| 247 |
|
|
|
|
|
|
|
| 248 |
def colpali_search_rerank(query):
|
| 249 |
if(st.session_state.show_columns == True):
|
| 250 |
print("show columns activated------------------------")
|