Archit Singh commited on
Commit
035ae2b
1 Parent(s): 543c0ea

update: fix dockerfile for simple no-build stages, new: add logic for ocr pipeline and streamlit

Browse files
Files changed (3) hide show
  1. Dockerfile +6 -6
  2. app.py +15 -3
  3. requirements.txt +5 -0
Dockerfile CHANGED
@@ -2,17 +2,17 @@ FROM python:3.9
2
 
3
  WORKDIR /code
4
 
 
 
5
  RUN pip install --upgrade pip
6
- RUN pip install torch torchvision
 
7
  RUN pip install -U openmim
8
  RUN mim install mmengine
9
  RUN mim install mmcv
10
  RUN mim install mmdet
11
 
12
  RUN git clone https://github.com/open-mmlab/mmocr.git
13
- RUN cd mmocr
14
- RUN pip install -v -e .
15
-
16
- COPY . .
17
 
18
- CMD ["python", "app.py"]
 
2
 
3
  WORKDIR /code
4
 
5
+ COPY . .
6
+
7
  RUN pip install --upgrade pip
8
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9
+
10
  RUN pip install -U openmim
11
  RUN mim install mmengine
12
  RUN mim install mmcv
13
  RUN mim install mmdet
14
 
15
  RUN git clone https://github.com/open-mmlab/mmocr.git
16
+ RUN pip install -v -e /code/mmocr
 
 
 
17
 
18
+ CMD ["streamlit", "run", "app.py"]
app.py CHANGED
@@ -1,5 +1,17 @@
 
 
1
  from mmocr.apis import MMOCRInferencer
 
 
2
 
3
- infer = MMOCRInferencer(rec='svtr-small')
4
- result = infer('demo/demo_text_recog.jpg', save_vis=True, return_vis=True)
5
- print(result['predictions'])
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+ import streamlit as st
3
  from mmocr.apis import MMOCRInferencer
4
+ import mmcv
5
+ import matplotlib.pyplot as plt
6
 
7
+ st.write('Hello, *World!* :sunglasses:')
8
+ dataset = load_dataset("katanaml-org/invoices-donut-data-v1")
9
+ st.write(f"{len(dataset)}")
10
+
11
+ infer = MMOCRInferencer(det='dbnetpp', rec='svtr-small', kie='SDMGR')
12
+ result = infer('demo/demo_kie.jpeg', save_vis=True)
13
+
14
+ predicted_img = mmcv.imread('results/vis/demo_kie.jpg')
15
+ plt.figure(figsize=(18, 32))
16
+ plt.imshow(mmcv.bgr2rgb(predicted_img))
17
+ plt.show()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ datasets
4
+ streamlit
5
+ matplotlib