myhloli commited on
Commit
66eda5d
β€’
1 Parent(s): 6aa7d5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -8,7 +8,7 @@ from pathlib import Path
8
  import re
9
 
10
  os.system('pip install -r requirements.txt')
11
- os.system('pip install -U magic_pdf-0.8.0a2-py3-none-any.whl')
12
  os.system('python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/')
13
 
14
  from huggingface_hub import snapshot_download
@@ -19,9 +19,7 @@ os.system('cp magic-pdf.template.json ~/magic-pdf.json')
19
  os.system(f"sed -i 's|/tmp/models|{model_dir}/models|g' /home/user/magic-pdf.json")
20
  os.system("sed -i 's|cpu|cuda|g' /home/user/magic-pdf.json")
21
 
22
- os.system('cp ch_PP-OCRv4_det_infer.tar /home/user/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer/ch_PP-OCRv4_det_infer.tar')
23
- os.system('cp ch_PP-OCRv4_rec_infer.tar /home/user/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar')
24
- os.system('cp ch_ppocr_mobile_v2.0_cls_infer.tar /home/user/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar')
25
 
26
  os.system("pip install gradio-pdf")
27
  from gradio_pdf import PDF
@@ -154,16 +152,16 @@ def init_model():
154
  model_manager = ModelSingleton()
155
  txt_model = model_manager.get_model(False, False)
156
  logger.info(f"txt_model init final")
157
- ocr_model = model_manager.get_model(True, False)
158
- logger.info(f"ocr_model init final")
159
  return 0
160
  except Exception as e:
161
  logger.exception(e)
162
  return -1
163
 
164
 
165
- # model_init = init_model()
166
- # logger.info(f"model_init: {model_init}")
167
 
168
 
169
  if __name__ == "__main__":
 
8
  import re
9
 
10
  os.system('pip install -r requirements.txt')
11
+ os.system('pip install -U magic_pdf-0.8.0a3-py3-none-any.whl')
12
  os.system('python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/')
13
 
14
  from huggingface_hub import snapshot_download
 
19
  os.system(f"sed -i 's|/tmp/models|{model_dir}/models|g' /home/user/magic-pdf.json")
20
  os.system("sed -i 's|cpu|cuda|g' /home/user/magic-pdf.json")
21
 
22
+ os.system('cp -r paddleocr /home/user/.paddleocr')
 
 
23
 
24
  os.system("pip install gradio-pdf")
25
  from gradio_pdf import PDF
 
152
  model_manager = ModelSingleton()
153
  txt_model = model_manager.get_model(False, False)
154
  logger.info(f"txt_model init final")
155
+ # ocr_model = model_manager.get_model(True, False)
156
+ # logger.info(f"ocr_model init final")
157
  return 0
158
  except Exception as e:
159
  logger.exception(e)
160
  return -1
161
 
162
 
163
+ model_init = init_model()
164
+ logger.info(f"model_init: {model_init}")
165
 
166
 
167
  if __name__ == "__main__":