Spaces:
Runtime error
Runtime error
Raymond Weitekamp
commited on
Commit
·
2412b6e
1
Parent(s):
d4167d9
fix refresh
Browse files
app.py
CHANGED
@@ -69,19 +69,13 @@ class OCRDataCollector:
|
|
69 |
return block
|
70 |
|
71 |
def submit_image(self, image, text_block):
|
72 |
-
if image is None:
|
73 |
-
message = "No image uploaded. Please try again or use 'Skip' to move on."
|
74 |
-
else:
|
75 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
76 |
self.collected_pairs.append({"text": text_block, "image": image, "timestamp": timestamp})
|
77 |
-
|
78 |
-
new_text = self.get_random_text_block()
|
79 |
-
return new_text, message
|
80 |
|
81 |
def skip_text(self, text_block):
|
82 |
-
|
83 |
-
message = "Skipped. Here is the next text."
|
84 |
-
return new_text, message
|
85 |
|
86 |
def create_gradio_interface():
|
87 |
collector = OCRDataCollector()
|
@@ -93,7 +87,6 @@ def create_gradio_interface():
|
|
93 |
text_box = gr.Textbox(value=collector.current_text_block, label="Text to Handwrite", interactive=False)
|
94 |
image_input = gr.Image(type="pil", label="Upload Handwritten Image", sources=["upload"])
|
95 |
|
96 |
-
|
97 |
with gr.Row():
|
98 |
submit_btn = gr.Button("Submit")
|
99 |
skip_btn = gr.Button("Skip")
|
@@ -101,13 +94,13 @@ def create_gradio_interface():
|
|
101 |
submit_btn.click(
|
102 |
fn=collector.submit_image,
|
103 |
inputs=[image_input, text_box],
|
104 |
-
outputs=
|
105 |
)
|
106 |
|
107 |
skip_btn.click(
|
108 |
fn=collector.skip_text,
|
109 |
inputs=text_box,
|
110 |
-
outputs=
|
111 |
)
|
112 |
|
113 |
|
|
|
69 |
return block
|
70 |
|
71 |
def submit_image(self, image, text_block):
|
72 |
+
if image is not None:
|
|
|
|
|
73 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
74 |
self.collected_pairs.append({"text": text_block, "image": image, "timestamp": timestamp})
|
75 |
+
return self.get_random_text_block()
|
|
|
|
|
76 |
|
77 |
def skip_text(self, text_block):
|
78 |
+
return self.get_random_text_block()
|
|
|
|
|
79 |
|
80 |
def create_gradio_interface():
|
81 |
collector = OCRDataCollector()
|
|
|
87 |
text_box = gr.Textbox(value=collector.current_text_block, label="Text to Handwrite", interactive=False)
|
88 |
image_input = gr.Image(type="pil", label="Upload Handwritten Image", sources=["upload"])
|
89 |
|
|
|
90 |
with gr.Row():
|
91 |
submit_btn = gr.Button("Submit")
|
92 |
skip_btn = gr.Button("Skip")
|
|
|
94 |
submit_btn.click(
|
95 |
fn=collector.submit_image,
|
96 |
inputs=[image_input, text_box],
|
97 |
+
outputs=text_box
|
98 |
)
|
99 |
|
100 |
skip_btn.click(
|
101 |
fn=collector.skip_text,
|
102 |
inputs=text_box,
|
103 |
+
outputs=text_box
|
104 |
)
|
105 |
|
106 |
|