Ramzan0553 commited on
Commit
7b55ecc
·
verified ·
1 Parent(s): ee9e3d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -5
app.py CHANGED
@@ -1,19 +1,45 @@
1
  import gradio as gr
2
  import cv2
3
- from PIL import Image
4
  import numpy as np
 
5
  from EasyOpticalCharacterRecognition import process_image
6
 
 
7
  def infer(image):
8
  img = np.array(image)
9
  annotated_img, result_text = process_image(img)
10
  return Image.fromarray(annotated_img), result_text
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  demo = gr.Interface(
13
  fn=infer,
14
- inputs=gr.Image(type="pil"),
15
- outputs=[gr.Image(type="pil", label="Annotated Image"), gr.Textbox(label="Classification Results")],
16
- title="Handwritten vs Computerized Text Detector",
17
- description="Upload an image containing text. The system detects text using EasyOCR and classifies each as handwritten or computerized using MobileNet."
 
 
 
 
 
18
  )
19
  demo.launch()
 
1
  import gradio as gr
2
  import cv2
 
3
  import numpy as np
4
+ from PIL import Image
5
  from EasyOpticalCharacterRecognition import process_image
6
 
7
+ # Wrapper function for Gradio interface
8
  def infer(image):
9
  img = np.array(image)
10
  annotated_img, result_text = process_image(img)
11
  return Image.fromarray(annotated_img), result_text
12
 
13
+ # Custom CSS for light blue background and bordered elements
14
+ custom_css = """
15
+ body
16
+ {
17
+ background-color: #e6f2ff;
18
+ }
19
+ .gradio-container
20
+ {
21
+ border-radius: 12px;
22
+ padding: 20px;
23
+ border: 2px solid #007acc;
24
+ }
25
+ .gr-input, .gr-output
26
+ {
27
+ border: 1px solid #007acc;
28
+ border-radius: 10px;
29
+ }
30
+ """
31
+
32
+ # Gradio Interface
33
  demo = gr.Interface(
34
  fn=infer,
35
+ inputs=gr.Image(type="pil", label="Upload Image"),
36
+ outputs=[
37
+ gr.Image(type="pil", label="Annotated Image"),
38
+ gr.Textbox(label="Detected Text and Classification")
39
+ ],
40
+ title="🧠 OCR & Text Type Classifier",
41
+ description="Application detect text from images and classifier classify text into Computerized & Handwritten Text.",
42
+ theme="soft", # Optional: you can also try "default" or "huggingface"
43
+ css=custom_css
44
  )
45
  demo.launch()