Spaces:
Running
Running
Commit
·
7904cc2
1
Parent(s):
a49fee8
Update flag button label
Browse files
app.py
CHANGED
@@ -27,9 +27,11 @@ to see the results.
|
|
27 |
</p>
|
28 |
"""
|
29 |
|
30 |
-
|
|
|
|
|
31 |
🚩 See something off? Your feedback makes a difference! Let us know by
|
32 |
-
flagging any outcomes that don't seem right. Click the `
|
33 |
to submit the image for review.
|
34 |
"""
|
35 |
|
@@ -73,7 +75,7 @@ with gr.Blocks(theme=theme, css=css, title="SEA.AI Vision Demo") as demo:
|
|
73 |
submit = gr.Button("Submit", variant="primary")
|
74 |
with gr.Column():
|
75 |
img_output = gr.Image(label="output", interactive=False)
|
76 |
-
flag = gr.Button(
|
77 |
notice = gr.Markdown(value=NOTICE, visible=False)
|
78 |
|
79 |
examples = gr.Examples(
|
@@ -89,7 +91,7 @@ with gr.Blocks(theme=theme, css=css, title="SEA.AI Vision Demo") as demo:
|
|
89 |
|
90 |
# event listeners
|
91 |
img_url.change(load_image_from_url, [img_url], img_input)
|
92 |
-
submit.click(check_image, [img_input]).success(
|
93 |
lambda image: inference(model, image),
|
94 |
[img_input],
|
95 |
img_output,
|
@@ -107,7 +109,7 @@ with gr.Blocks(theme=theme, css=css, title="SEA.AI Vision Demo") as demo:
|
|
107 |
def _show_hide_flagging(_img_input, _img_output):
|
108 |
visible = _img_output and _img_input["orig_name"] not in os.listdir("examples")
|
109 |
return {
|
110 |
-
flag: gr.Button(
|
111 |
notice: gr.Markdown(value=NOTICE, visible=visible),
|
112 |
}
|
113 |
|
@@ -115,8 +117,11 @@ with gr.Blocks(theme=theme, css=css, title="SEA.AI Vision Demo") as demo:
|
|
115 |
hf_writer.setup([img_input], "flagged")
|
116 |
|
117 |
# Sequential logic when flag button is clicked
|
118 |
-
flag.click(lambda: gr.Info("Thank you for contributing!")).then(
|
119 |
-
lambda: {flag: gr.Button(
|
|
|
|
|
|
|
120 |
).then(
|
121 |
lambda *args: hf_writer.flag(args),
|
122 |
[img_input, flag],
|
|
|
27 |
</p>
|
28 |
"""
|
29 |
|
30 |
+
FLAG_TXT = "Report Mis-detection"
|
31 |
+
|
32 |
+
NOTICE = f"""
|
33 |
🚩 See something off? Your feedback makes a difference! Let us know by
|
34 |
+
flagging any outcomes that don't seem right. Click the `{FLAG_TXT}` button
|
35 |
to submit the image for review.
|
36 |
"""
|
37 |
|
|
|
75 |
submit = gr.Button("Submit", variant="primary")
|
76 |
with gr.Column():
|
77 |
img_output = gr.Image(label="output", interactive=False)
|
78 |
+
flag = gr.Button(FLAG_TXT, visible=False)
|
79 |
notice = gr.Markdown(value=NOTICE, visible=False)
|
80 |
|
81 |
examples = gr.Examples(
|
|
|
91 |
|
92 |
# event listeners
|
93 |
img_url.change(load_image_from_url, [img_url], img_input)
|
94 |
+
submit.click(check_image, [img_input], show_api=False).success(
|
95 |
lambda image: inference(model, image),
|
96 |
[img_input],
|
97 |
img_output,
|
|
|
109 |
def _show_hide_flagging(_img_input, _img_output):
|
110 |
visible = _img_output and _img_input["orig_name"] not in os.listdir("examples")
|
111 |
return {
|
112 |
+
flag: gr.Button(FLAG_TXT, interactive=True, visible=visible),
|
113 |
notice: gr.Markdown(value=NOTICE, visible=visible),
|
114 |
}
|
115 |
|
|
|
117 |
hf_writer.setup([img_input], "flagged")
|
118 |
|
119 |
# Sequential logic when flag button is clicked
|
120 |
+
flag.click(lambda: gr.Info("Thank you for contributing!"), show_api=False).then(
|
121 |
+
lambda: {flag: gr.Button(FLAG_TXT, interactive=False)},
|
122 |
+
[],
|
123 |
+
[flag],
|
124 |
+
show_api=False,
|
125 |
).then(
|
126 |
lambda *args: hf_writer.flag(args),
|
127 |
[img_input, flag],
|