tomofi commited on
Commit
9faba95
β€’
1 Parent(s): 5d013d8

Add application file

Browse files
Files changed (6) hide show
  1. README.md +31 -7
  2. app.py +20 -0
  3. example_1.png +0 -0
  4. example_2.jpg +0 -0
  5. packages.txt +1 -0
  6. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,37 @@
1
  ---
2
- title: CRAFT
3
- emoji: 🐒
4
- colorFrom: yellow
5
- colorTo: green
6
  sdk: gradio
7
- sdk_version: 2.8.10
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: CRAFT OCR
3
+ emoji: πŸ‘
4
+ colorFrom: pink
5
+ colorTo: purple
6
  sdk: gradio
 
7
  app_file: app.py
8
  pinned: false
 
9
  ---
10
 
11
+ # Configuration
12
+
13
+ `title`: _string_
14
+ Display title for the Space
15
+
16
+ `emoji`: _string_
17
+ Space emoji (emoji-only character allowed)
18
+
19
+ `colorFrom`: _string_
20
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
21
+
22
+ `colorTo`: _string_
23
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
24
+
25
+ `sdk`: _string_
26
+ Can be either `gradio` or `streamlit`
27
+
28
+ `sdk_version` : _string_
29
+ Only applicable for `streamlit` SDK.
30
+ See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
+
32
+ `app_file`: _string_
33
+ Path to your main application file (which contains either `gradio` or `streamlit` Python code).
34
+ Path is relative to the root of the repository.
35
+
36
+ `pinned`: _boolean_
37
+ Whether the Space stays on top of your list.
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from craft_hw_ocr import OCR
3
+
4
+ ocr = OCR.load_models()
5
+
6
+ def do_ocr(inp):
7
+ img, results = OCR.detection(inp, ocr[2])
8
+ bboxes, text = OCR.recoginition(img, results, ocr[0], ocr[1])
9
+ return OCR.visualize(img, results), text
10
+
11
+ inputs = gr.inputs.Image()
12
+ o1 = gr.outputs.Image()
13
+ o2 = gr.outputs.Textbox()
14
+
15
+ title = "CRAFT-OCR"
16
+ description = "OCR of both handwriting and printed text using CRAFT Text detector and TrOCR recognition, detection of lines and extraction of them are happening here because TrOCR pre-trained models are modelled on IAM lines dataset and the same needs to be implemented here."
17
+ examples=[['example_1.png'],['example_2.jpg']]
18
+
19
+ article = "<p style='text-align: center'><a href='https://github.com/Vishnunkumar/craft_hw_ocr' target='_blank'>craft_hw_ocr</a></p><p style='text-align: center'> <p style='text-align: center'><a href='https://github.com/fcakyon/craft-text-detector' target='_blank'>craft-text-detector</a></p><p style='text-align: center'>"
20
+ gr.Interface(fn=do_ocr, inputs=inputs, outputs=[o1, o2], title=title, description=description, article=article, examples=examples, enable_queue=True).launch()
example_1.png ADDED
example_2.jpg ADDED
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python3-opencv
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ craft-hw-ocr==1.1
2
+ gradio
3
+ opencv-python-headless==4.5.5.62