Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,8 @@ def read_fn(path):
|
|
37 |
disk_rw = DiskReaderWriter(os.path.dirname(path))
|
38 |
return disk_rw.read(os.path.basename(path), AbsReaderWriter.MODE_BIN)
|
39 |
|
40 |
-
|
|
|
41 |
def parse_pdf(doc_path, output_dir, end_page_id):
|
42 |
os.makedirs(output_dir, exist_ok=True)
|
43 |
|
@@ -140,6 +141,27 @@ def show_pdf(file):
|
|
140 |
latex_delimiters = [{"left": "$$", "right": "$$", "display": True},
|
141 |
{"left": '$', "right": '$', "display": False}]
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
if __name__ == "__main__":
|
144 |
with gr.Blocks() as demo:
|
145 |
with gr.Row():
|
|
|
37 |
disk_rw = DiskReaderWriter(os.path.dirname(path))
|
38 |
return disk_rw.read(os.path.basename(path), AbsReaderWriter.MODE_BIN)
|
39 |
|
40 |
+
|
41 |
+
@spaces.GPU
|
42 |
def parse_pdf(doc_path, output_dir, end_page_id):
|
43 |
os.makedirs(output_dir, exist_ok=True)
|
44 |
|
|
|
141 |
latex_delimiters = [{"left": "$$", "right": "$$", "display": True},
|
142 |
{"left": '$', "right": '$', "display": False}]
|
143 |
|
144 |
+
|
145 |
+
from magic_pdf.model.doc_analyze_by_custom_model import ModelSingleton
|
146 |
+
|
147 |
+
def init_model():
|
148 |
+
from magic_pdf.model.doc_analyze_by_custom_model import ModelSingleton
|
149 |
+
try:
|
150 |
+
model_manager = ModelSingleton()
|
151 |
+
txt_model = model_manager.get_model(False, False)
|
152 |
+
logger.info(f"txt_model init final")
|
153 |
+
ocr_model = model_manager.get_model(True, False)
|
154 |
+
logger.info(f"ocr_model init final")
|
155 |
+
return 0
|
156 |
+
except Exception as e:
|
157 |
+
logger.exception(e)
|
158 |
+
return -1
|
159 |
+
|
160 |
+
|
161 |
+
model_init = init_model()
|
162 |
+
logger.info(f"model_init: {model_init}")
|
163 |
+
|
164 |
+
|
165 |
if __name__ == "__main__":
|
166 |
with gr.Blocks() as demo:
|
167 |
with gr.Row():
|