Spaces:
Sleeping
Sleeping
Commit
·
fda61d7
1
Parent(s):
196a03f
adjust layout
Browse files
app.py
CHANGED
|
@@ -80,19 +80,19 @@ class App:
|
|
| 80 |
self.curr_kana_image = gr.State(self.default_kana_image)
|
| 81 |
|
| 82 |
def init_practice_tab(self):
|
| 83 |
-
|
| 84 |
-
self.
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
-
with gr.Row():
|
| 94 |
self.target_txt = gr.Textbox(self.default_roma, label="🎯 練習目標")
|
| 95 |
-
self.result_txt = gr.
|
| 96 |
|
| 97 |
with gr.Row():
|
| 98 |
self.next_btn = gr.Button("👉 下一個字")
|
|
@@ -211,7 +211,7 @@ class App:
|
|
| 211 |
image[image != 255] = 0
|
| 212 |
_, results = self.recognizer.recognize(image)
|
| 213 |
|
| 214 |
-
return f"正解:{curr_kana}
|
| 215 |
f"{result.char} ({self.conv_kana_to_roma(result.char)}): {result.prob:.2%}"
|
| 216 |
for items in results
|
| 217 |
for result in items
|
|
|
|
| 80 |
self.curr_kana_image = gr.State(self.default_kana_image)
|
| 81 |
|
| 82 |
def init_practice_tab(self):
|
| 83 |
+
with gr.Group():
|
| 84 |
+
self.sketchpad = gr.Sketchpad(
|
| 85 |
+
self.default_kana_image,
|
| 86 |
+
type="numpy",
|
| 87 |
+
image_mode="RGB",
|
| 88 |
+
brush=gr.Brush(self.brush_size, self.brush_color),
|
| 89 |
+
eraser=False,
|
| 90 |
+
layers=False,
|
| 91 |
+
label="🖊️ 寫字板",
|
| 92 |
+
)
|
| 93 |
|
|
|
|
| 94 |
self.target_txt = gr.Textbox(self.default_roma, label="🎯 練習目標")
|
| 95 |
+
self.result_txt = gr.TextArea(lines=2, label="💯 辨識結果")
|
| 96 |
|
| 97 |
with gr.Row():
|
| 98 |
self.next_btn = gr.Button("👉 下一個字")
|
|
|
|
| 211 |
image[image != 255] = 0
|
| 212 |
_, results = self.recognizer.recognize(image)
|
| 213 |
|
| 214 |
+
return f"正解:{curr_kana}\n辨識:" + ", ".join(
|
| 215 |
f"{result.char} ({self.conv_kana_to_roma(result.char)}): {result.prob:.2%}"
|
| 216 |
for items in results
|
| 217 |
for result in items
|