Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from deepdoctection.dataflow import DataFromList
|
2 |
+
from deepdoctection import get_dd_analyzer
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
def analyze_image(img):
|
7 |
+
# creating an image object and passing to the analyzer by using dataflows
|
8 |
+
image = Image(file_name="input.png", location="")
|
9 |
+
image.image = img
|
10 |
+
|
11 |
+
df = DataFromList(lst=[image])
|
12 |
+
|
13 |
+
analyzer = get_dd_analyzer(ocr=False)
|
14 |
+
|
15 |
+
df = analyzer.analyze(dataset_dataflow=df)
|
16 |
+
df.reset_state()
|
17 |
+
dp = next(iter(df))
|
18 |
+
|
19 |
+
|
20 |
+
return dp.viz(show_cells=False)
|
21 |
+
|
22 |
+
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
23 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
24 |
+
|
25 |
+
title = "Deepdoctection"
|
26 |
+
description = ""
|
27 |
+
|
28 |
+
# examples = [
|
29 |
+
# ['example-table.jpeg'],
|
30 |
+
# ['paper-image.jpeg']
|
31 |
+
|
32 |
+
# ]
|
33 |
+
|
34 |
+
gr.Interface(analyze_image, inputs, outputs, title=title, description=description, examples=examples).launch()
|