Pisethan commited on
Commit
79d8e1d
·
verified ·
1 Parent(s): 1a6b36c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datasets import load_dataset
3
+ from PIL import Image
4
+
5
+ # Load dataset
6
+ dataset = load_dataset("Pisethan/sangapac_ocr")
7
+
8
+ # Function to display image and text
9
+ def display_data(index):
10
+ row = dataset["train"][index]
11
+ image = Image.open(row["image_path"])
12
+ text = row["text"]
13
+ return image, text
14
+
15
+ # Create Gradio Interface
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("### OCR Dataset Viewer")
18
+ index_input = gr.Slider(0, len(dataset["train"]) - 1, step=1, value=0, label="Select Index")
19
+ output_image = gr.Image(label="Image")
20
+ output_text = gr.Textbox(label="OCR Text")
21
+ index_input.change(display_data, inputs=index_input, outputs=[output_image, output_text])
22
+
23
+ demo.launch()