gabar92 commited on
Commit
9a7a057
·
1 Parent(s): 60c1d6c

resize qr code and add examples

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -62,15 +62,26 @@ def main():
62
  [Image.open(os.path.join(args.example_image_path, image_path))]
63
  for image_path in os.listdir(args.example_image_path)
64
  ]
65
-
66
- description = """
67
- Welcome to the Document Image Enhancement (DIE) model demo on Hugging Face!
68
-
69
- This application showcases a specialized AI model by the Artificial Intelligence group at the Alfréd Rényi Institute of Mathematics, aimed at enhancing and restoring archival document images. This model removes domain-specific noise, preserving clarity and improving OCR accuracy, particularly for aged and historical documents.
70
-
71
- Contact: [email protected]
72
-
73
- """
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  # Partial function for inference with model and device arguments
76
  partial_die_inference = partial(die_inference, die_model=die_model, device=args.device)
@@ -85,7 +96,7 @@ def main():
85
  gr.Markdown(description)
86
  with gr.Column():
87
  # Display QR code as an image in Gradio
88
- gr.Image(value=Image.open("logo/qr-code.png"), label="QR Code")
89
 
90
  with gr.Row():
91
  with gr.Column():
@@ -95,7 +106,14 @@ def main():
95
 
96
  with gr.Column():
97
  output_image = gr.Image(type="pil", label="Enhanced Document Image")
98
-
 
 
 
 
 
 
 
99
  # Button trigger for inference
100
  run_button.click(partial_die_inference, [input_image, num_iterations], output_image)
101
 
 
62
  [Image.open(os.path.join(args.example_image_path, image_path))]
63
  for image_path in os.listdir(args.example_image_path)
64
  ]
65
+
66
+ description = "Welcome to the Document Image Enhancement (DIE) model demo on Hugging Face!\n\n" \
67
+ "" \
68
+ "This interactive application showcases a specialized AI model developed by " \
69
+ "the [Artificial Intelligence group](https://ai.renyi.hu) at the [Alfréd Rényi Institute of Mathematics](https://renyi.hu).\n\n" \
70
+ "" \
71
+ "Our DIE model is designed to enhance and restore archival and aged document images " \
72
+ "by removing various types of degradation, thereby making historical documents more legible " \
73
+ "and suitable for Optical Character Recognition (OCR) processing.\n\n" \
74
+ "" \
75
+ "The model effectively tackles 20-30 types of domain-specific noise found in historical records, " \
76
+ "such as scribbles, bleed-through text, faded or worn text, blurriness, textured noise, " \
77
+ "and unwanted background elements. " \
78
+ "By applying deep learning techniques, specifically a U-Net-based architecture, " \
79
+ "the model accurately cleans and clarifies text while preserving original details. " \
80
+ "This improved clarity dramatically boosts OCR accuracy, making it an ideal " \
81
+ "pre-processing tool in digitization workflows.\n\n" \
82
+ "" \
83
+ "If you’re interested in learning more about the model’s capabilities or potential applications, " \
84
+ "please contact us at: [email protected].\n"
85
 
86
  # Partial function for inference with model and device arguments
87
  partial_die_inference = partial(die_inference, die_model=die_model, device=args.device)
 
96
  gr.Markdown(description)
97
  with gr.Column():
98
  # Display QR code as an image in Gradio
99
+ gr.Image(value=Image.open("logo/qr-code.png").resize((200, 200)), label="QR Code")
100
 
101
  with gr.Row():
102
  with gr.Column():
 
106
 
107
  with gr.Column():
108
  output_image = gr.Image(type="pil", label="Enhanced Document Image")
109
+
110
+ # Display example images
111
+ gr.Examples(
112
+ examples=example_image_list,
113
+ inputs=[input_image],
114
+ label="Example Images",
115
+ )
116
+
117
  # Button trigger for inference
118
  run_button.click(partial_die_inference, [input_image, num_iterations], output_image)
119