Spaces:
Runtime error
Runtime error
Peng Shiya
commited on
Commit
•
7ac4295
1
Parent(s):
c4af616
feature: updated feedback
Browse files
app.py
CHANGED
@@ -58,15 +58,14 @@ with block:
|
|
58 |
run_btn = gr.Button('Run', variant = 'primary')
|
59 |
with gr.Column(scale=2):
|
60 |
with gr.Accordion('Provide Feedback'):
|
|
|
61 |
with gr.Row():
|
62 |
upvote_button = gr.Button('Upvote')
|
63 |
downvote_button = gr.Button('Downvote')
|
64 |
-
feedback_textbox = gr.Textbox(lines=3, show_label=False)
|
65 |
-
feedback_submit_button = gr.Button('Submit')
|
66 |
# components
|
67 |
components = {
|
68 |
point_coords, point_labels, raw_image, masks, cutout_idx,
|
69 |
-
feedback, upvote_button, downvote_button, feedback_textbox,
|
70 |
input_image, point_label_radio, reset_btn, run_btn, masks_annotated_image}
|
71 |
|
72 |
# event - init coords
|
@@ -129,21 +128,16 @@ with block:
|
|
129 |
masks_annotated_image.select(on_masks_annotated_image_select, components, [cutout_idx, cutout_galary, feedback], queue=False)
|
130 |
|
131 |
# event - feedback
|
132 |
-
def on_feedback_submit_button_click(inputs):
|
133 |
-
inputs[feedback].save_feedback(feedback_str=inputs[feedback_textbox])
|
134 |
-
gr.Info('Thanks for your feedback')
|
135 |
-
return inputs[feedback], None
|
136 |
-
feedback_submit_button.click(on_feedback_submit_button_click, {feedback, feedback_textbox}, [feedback, feedback_textbox], queue=False)
|
137 |
def on_upvote_button_click(inputs):
|
138 |
-
inputs[feedback].save_feedback(like=1)
|
139 |
gr.Info('Thanks for your feedback')
|
140 |
-
return {feedback:inputs[feedback]}
|
141 |
-
upvote_button.click(on_upvote_button_click,components,[feedback,
|
142 |
def on_downvote_button_click(inputs):
|
143 |
-
inputs[feedback].save_feedback(like=-1)
|
144 |
gr.Info('Thanks for your feedback')
|
145 |
-
return {feedback:inputs[feedback]}
|
146 |
-
downvote_button.click(on_downvote_button_click,components,[feedback,
|
147 |
if __name__ == '__main__':
|
148 |
block.queue()
|
149 |
block.launch()
|
|
|
58 |
run_btn = gr.Button('Run', variant = 'primary')
|
59 |
with gr.Column(scale=2):
|
60 |
with gr.Accordion('Provide Feedback'):
|
61 |
+
feedback_textbox = gr.Textbox(lines=3, show_label=False, info="Comments (Leave blank to vote without any comments)")
|
62 |
with gr.Row():
|
63 |
upvote_button = gr.Button('Upvote')
|
64 |
downvote_button = gr.Button('Downvote')
|
|
|
|
|
65 |
# components
|
66 |
components = {
|
67 |
point_coords, point_labels, raw_image, masks, cutout_idx,
|
68 |
+
feedback, upvote_button, downvote_button, feedback_textbox,
|
69 |
input_image, point_label_radio, reset_btn, run_btn, masks_annotated_image}
|
70 |
|
71 |
# event - init coords
|
|
|
128 |
masks_annotated_image.select(on_masks_annotated_image_select, components, [cutout_idx, cutout_galary, feedback], queue=False)
|
129 |
|
130 |
# event - feedback
|
|
|
|
|
|
|
|
|
|
|
131 |
def on_upvote_button_click(inputs):
|
132 |
+
inputs[feedback].save_feedback(like=1, feedback_str=inputs[feedback_textbox])
|
133 |
gr.Info('Thanks for your feedback')
|
134 |
+
return {feedback:inputs[feedback],feedback_textbox:None}
|
135 |
+
upvote_button.click(on_upvote_button_click,components,[feedback, feedback_textbox], queue=False)
|
136 |
def on_downvote_button_click(inputs):
|
137 |
+
inputs[feedback].save_feedback(like=-1, feedback_str=inputs[feedback_textbox])
|
138 |
gr.Info('Thanks for your feedback')
|
139 |
+
return {feedback:inputs[feedback],feedback_textbox:None}
|
140 |
+
downvote_button.click(on_downvote_button_click,components,[feedback, feedback_textbox], queue=False)
|
141 |
if __name__ == '__main__':
|
142 |
block.queue()
|
143 |
block.launch()
|