Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Importing the library
|
2 |
+
import keras_ocr
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
# keras-ocr will automatically download pretrained
|
7 |
+
# weights for the detector and recognizer.
|
8 |
+
pipeline = keras_ocr.pipeline.Pipeline()
|
9 |
+
def classify_image(file_name):
|
10 |
+
images = [keras_ocr.tools.read(file_name.name.replace("\\",'/'))]
|
11 |
+
prediction_groups = pipeline.recognize(images)
|
12 |
+
text = ""
|
13 |
+
for i in prediction_groups[0]:
|
14 |
+
text = text+ " " + i[0]
|
15 |
+
return text
|
16 |
+
|
17 |
+
|
18 |
+
image = gr.inputs.File( file_count="single",type="file", label="Fichier à Traiter (sous fichier .pgm)")
|
19 |
+
# label = gr.outputs.Label(num_top_classes=3)
|
20 |
+
|
21 |
+
gr.Interface(
|
22 |
+
fn=classify_image,
|
23 |
+
inputs=image,
|
24 |
+
outputs="text",
|
25 |
+
interpretation="default",
|
26 |
+
live=True,
|
27 |
+
theme="dark-peach",
|
28 |
+
title="API OCR",
|
29 |
+
description="Cette API est utilisé extraire du texte dans une image"
|
30 |
+
).launch()
|