Spaces:
Sleeping
Sleeping
Prathmesh48
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ from io import BytesIO
|
|
16 |
from PyPDF2 import PdfReader
|
17 |
import hashlib
|
18 |
import os
|
|
|
19 |
|
20 |
# File Imports
|
21 |
from embedding import get_embeddings, get_image_embeddings, get_embed_chroma , imporve_text # Ensure this file/module is available
|
@@ -24,10 +25,21 @@ from search import *
|
|
24 |
|
25 |
|
26 |
# Chroma Connections
|
27 |
-
client = chromadb.PersistentClient(path="
|
28 |
collection = client.get_or_create_collection(name="data", metadata={"hnsw:space": "l2"})
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def generate_hash(content):
|
32 |
return hashlib.sha256(content.encode('utf-8')).hexdigest()
|
33 |
|
@@ -243,6 +255,15 @@ with st.sidebar:
|
|
243 |
|
244 |
top_similar_count = st.number_input("Top Similarities to be Displayed", value=3, min_value=1, step=1, format="%i")
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
if st.button('Check for Infringement'):
|
247 |
global log_output # Placeholder for log output
|
248 |
|
|
|
16 |
from PyPDF2 import PdfReader
|
17 |
import hashlib
|
18 |
import os
|
19 |
+
import shutil
|
20 |
|
21 |
# File Imports
|
22 |
from embedding import get_embeddings, get_image_embeddings, get_embed_chroma , imporve_text # Ensure this file/module is available
|
|
|
25 |
|
26 |
|
27 |
# Chroma Connections
|
28 |
+
client = chromadb.PersistentClient(path="embeddings")
|
29 |
collection = client.get_or_create_collection(name="data", metadata={"hnsw:space": "l2"})
|
30 |
|
31 |
|
32 |
+
def zip_folder(folder_path, zip_name):
|
33 |
+
# Create a zip file from the folder
|
34 |
+
shutil.make_archive(zip_name, 'zip', folder_path)
|
35 |
+
return zip_name + '.zip'
|
36 |
+
|
37 |
+
folder_path = '/home/user/app/embedding'
|
38 |
+
zip_name = 'embedding'
|
39 |
+
|
40 |
+
# st.title("Download Embedding Folder")
|
41 |
+
|
42 |
+
|
43 |
def generate_hash(content):
|
44 |
return hashlib.sha256(content.encode('utf-8')).hexdigest()
|
45 |
|
|
|
255 |
|
256 |
top_similar_count = st.number_input("Top Similarities to be Displayed", value=3, min_value=1, step=1, format="%i")
|
257 |
|
258 |
+
if st.button("Download"):
|
259 |
+
zip_file = zip_folder(folder_path, zip_name)
|
260 |
+
with open(zip_file, "rb") as f:
|
261 |
+
st.download_button(
|
262 |
+
label="Download ZIP",
|
263 |
+
data=f,
|
264 |
+
file_name=zip_file,
|
265 |
+
mime="application/zip"
|
266 |
+
)
|
267 |
if st.button('Check for Infringement'):
|
268 |
global log_output # Placeholder for log output
|
269 |
|