yolo12138 commited on
Commit
631b608
·
1 Parent(s): 1a23695

fix: docker 环境部署

Browse files
Files changed (3) hide show
  1. Dockerfile +6 -5
  2. app.py +15 -14
  3. packages.txt +0 -3
Dockerfile CHANGED
@@ -1,6 +1,6 @@
 
1
  FROM python:3.10
2
 
3
- # FROM python:3.10-slim-bullseye
4
  ENV CUDA_VISIBLE_DEVICES=-1
5
  ARG PIP_NO_CACHE_DIR=1
6
 
@@ -16,9 +16,10 @@ RUN pip install paddleocr==2.7.0.3 \
16
  && pip uninstall -y opencv-python opencv-contrib-python \
17
  && pip install opencv-python-headless
18
 
19
- RUN mkdir /app
20
- COPY app.py /app
21
- COPY example_imgs/ /app/example_imgs/
22
- WORKDIR /app
 
23
 
24
  CMD ["python", "-u", "app.py"]
 
1
+ # https://huggingface.co/spaces/gaunernst/layoutlm-docvqa-paddleocr/blob/main/Dockerfile
2
  FROM python:3.10
3
 
 
4
  ENV CUDA_VISIBLE_DEVICES=-1
5
  ARG PIP_NO_CACHE_DIR=1
6
 
 
16
  && pip uninstall -y opencv-python opencv-contrib-python \
17
  && pip install opencv-python-headless
18
 
19
+ RUN useradd -m -u 1000 user
20
+ USER user
21
+ ENV HOME=/home/user
22
+ WORKDIR $HOME/app
23
+ COPY --chown=user . $HOME/app
24
 
25
  CMD ["python", "-u", "app.py"]
app.py CHANGED
@@ -53,18 +53,19 @@ examples = [
53
 
54
  css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
55
 
56
- demo = gr.Interface(
57
- inference,
58
- [gr.Image(type='pil', label='Input'),
59
- gr.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], value='ch', label='language'),
60
- gr.Slider(0.1, 1, 0.5, step=0.1, label='confidence_threshold')
61
- ],
62
- # 输出
63
- [gr.Image(type='pil', label='Output'), gr.Dataframe(headers=[ 'bbox', 'score', 'text'], label='Result')],
64
- title=title,
65
- description=description,
66
- examples=examples,
67
- css=css,
 
68
  )
69
- demo.queue(max_size=10)
70
- demo.launch(debug=True, share=True)
 
53
 
54
  css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
55
 
56
+ if __name__ == '__main__':
57
+ demo = gr.Interface(
58
+ inference,
59
+ [gr.Image(type='pil', label='Input'),
60
+ gr.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], value='ch', label='language'),
61
+ gr.Slider(0.1, 1, 0.5, step=0.1, label='confidence_threshold')
62
+ ],
63
+ # 输出
64
+ [gr.Image(type='pil', label='Output'), gr.Dataframe(headers=[ 'bbox', 'score', 'text'], label='Result')],
65
+ title=title,
66
+ description=description,
67
+ examples=examples,
68
+ css=css,
69
  )
70
+ demo.queue(max_size=10)
71
+ demo.launch(debug=True, server_name="0.0.0.0")
packages.txt DELETED
@@ -1,3 +0,0 @@
1
- ffmpeg
2
- libsm6
3
- libxext6