Spaces:
Running
on
Zero
Running
on
Zero
fix bug
Browse files- app.py +3 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -15,6 +15,7 @@ import torch
|
|
15 |
import fitz
|
16 |
import threading
|
17 |
import gradio as gr
|
|
|
18 |
|
19 |
|
20 |
def get_image_md5(img: Image.Image):
|
@@ -78,6 +79,7 @@ class PDFVisualRetrieval:
|
|
78 |
self.images[knowledge_base_name][image_md5] = image
|
79 |
return
|
80 |
|
|
|
81 |
def add_pdf_gradio(self, pdf_file_binary, progress=gr.Progress()):
|
82 |
knowledge_base_name = calculate_md5_from_binary(pdf_file_binary)
|
83 |
if knowledge_base_name not in self.reps:
|
@@ -99,6 +101,7 @@ class PDFVisualRetrieval:
|
|
99 |
self.images[knowledge_base_name][image_md5] = image
|
100 |
return knowledge_base_name
|
101 |
|
|
|
102 |
def retrieve_gradio(self, knowledge_base: str, query: str, topk: int):
|
103 |
doc_reps = list(self.reps[knowledge_base].values())
|
104 |
query_with_instruction = "Represent this query for retrieving relavant document: " + query
|
|
|
15 |
import fitz
|
16 |
import threading
|
17 |
import gradio as gr
|
18 |
+
import spaces
|
19 |
|
20 |
|
21 |
def get_image_md5(img: Image.Image):
|
|
|
79 |
self.images[knowledge_base_name][image_md5] = image
|
80 |
return
|
81 |
|
82 |
+
@spaces.GPU
|
83 |
def add_pdf_gradio(self, pdf_file_binary, progress=gr.Progress()):
|
84 |
knowledge_base_name = calculate_md5_from_binary(pdf_file_binary)
|
85 |
if knowledge_base_name not in self.reps:
|
|
|
101 |
self.images[knowledge_base_name][image_md5] = image
|
102 |
return knowledge_base_name
|
103 |
|
104 |
+
@spaces.GPU
|
105 |
def retrieve_gradio(self, knowledge_base: str, query: str, topk: int):
|
106 |
doc_reps = list(self.reps[knowledge_base].values())
|
107 |
query_with_instruction = "Represent this query for retrieving relavant document: " + query
|
requirements.txt
CHANGED
@@ -6,4 +6,5 @@ torch==2.2.0
|
|
6 |
torchvision
|
7 |
sentencepiece==0.1.99
|
8 |
numpy==1.26.0
|
9 |
-
transformers==4.40.2
|
|
|
|
6 |
torchvision
|
7 |
sentencepiece==0.1.99
|
8 |
numpy==1.26.0
|
9 |
+
transformers==4.40.2
|
10 |
+
timm
|