hackergeek commited on
Commit
20300f6
·
verified ·
1 Parent(s): 5dddd24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -1,3 +1,25 @@
1
  import trackio
 
 
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  trackio.show()
 
1
  import trackio
2
+ import gradio as gr
3
+ from hezar.models import Model
4
 
5
+ # Load your model
6
+ crnn = Model.load("hezarai/crnn-base-fa-v2")
7
+
8
+ # Define prediction function
9
+ def ocr_predict(image):
10
+ texts = crnn.predict([image])
11
+ return "\n".join(texts)
12
+
13
+ # Create Gradio interface
14
+ iface = gr.Interface(
15
+ fn=ocr_predict,
16
+ inputs=gr.Image(type="filepath"), # Accepts uploaded images
17
+ outputs=gr.Textbox(label="Detected Text"),
18
+ title="Farsi OCR",
19
+ description="Upload an image and extract Farsi text using CRNN."
20
+ )
21
+
22
+ # Launch the app
23
+ if __name__ == "__main__":
24
+ iface.launch()
25
  trackio.show()