glitchbench commited on
Commit
9a0f9a2
1 Parent(s): c39134c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -14
app.py CHANGED
@@ -30,8 +30,9 @@ DEFAILT_USERNAME_MESSAGE = "You must be logged in befor starting to label images
30
  REPO_URL = "glitchbench/GlitchBenchReviewData"
31
  DATASET_URL = "glitchbench/GlitchBench"
32
 
33
- SUBMIT_MESSAGE = "Submit the description"
34
- SKIP_MESSAGE = "Skip, I can not spot the bug!"
 
35
 
36
  glitchbench_dataset = load_dataset(DATASET_URL)["validation"]
37
  dataset_size = len(glitchbench_dataset)
@@ -44,6 +45,61 @@ JSON_DATASET_DATA_DIR = JSON_DATASET_DIR / "data"
44
  JSON_DATASET_PATH = JSON_DATASET_DATA_DIR / f"labels-{uuid4()}.json"
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  if not JSON_DATASET_DIR.exists():
48
  JSON_DATASET_DIR.mkdir()
49
 
@@ -141,7 +197,10 @@ def write_user_description(username_label, image_id, user_description, skip_or_s
141
 
142
  with gr.Blocks() as demo:
143
  gr.Markdown("## GlitchBench Dataset Labeling Tool")
144
- gr.Markdown("Help us to clean and label the GlitchBench dataset.")
 
 
 
145
 
146
  with gr.Row():
147
  username_label = gr.Text(label="Username", interactive=False)
@@ -152,14 +211,15 @@ with gr.Blocks() as demo:
152
 
153
  username_label.attach_load_event(set_username, None)
154
 
155
- glitch_image = gr.Image(label="Image")
156
- glitch_image_id = gr.Textbox(label="Image ID", visible=False)
157
-
158
  with gr.Row():
159
- user_description = gr.Textbox(lines=5, label="Description")
160
- with gr.Column():
161
- submit_button = gr.Button(SUBMIT_MESSAGE)
162
- Skip_btton = gr.Button(SKIP_MESSAGE)
 
 
 
 
163
 
164
  remaining_batch = gr.State()
165
 
@@ -171,9 +231,9 @@ with gr.Blocks() as demo:
171
  outputs=[glitch_image, glitch_image_id, user_description],
172
  )
173
 
174
- submit_button.click(
175
  write_user_description,
176
- inputs=[username_label, glitch_image_id, user_description, submit_button],
177
  outputs=[],
178
  ).then(
179
  show_random_sample,
@@ -181,9 +241,9 @@ with gr.Blocks() as demo:
181
  outputs=[glitch_image, glitch_image_id, user_description],
182
  )
183
 
184
- Skip_btton.click(
185
  write_user_description,
186
- inputs=[username_label, glitch_image_id, user_description, Skip_btton],
187
  outputs=[],
188
  ).then(
189
  show_random_sample,
 
30
  REPO_URL = "glitchbench/GlitchBenchReviewData"
31
  DATASET_URL = "glitchbench/GlitchBench"
32
 
33
+ SUBMIT_MESSAGE = "Submit the description"
34
+ IDUNNU_MESSAGE = "🤷 I don't know what to do with this image"
35
+ SKIP_MESSAGE = "⏭️ Skip, for now"
36
 
37
  glitchbench_dataset = load_dataset(DATASET_URL)["validation"]
38
  dataset_size = len(glitchbench_dataset)
 
45
  JSON_DATASET_PATH = JSON_DATASET_DATA_DIR / f"labels-{uuid4()}.json"
46
 
47
 
48
+ INSTRUCTIONS = """
49
+ <div>
50
+ <section>
51
+ <h2>Introduction</h2>
52
+ <p>Welcome to the GlitchBench Dataset Labeling Tool! Your contribution is vital in helping us clean and label the dataset accurately. This tool is designed to be intuitive and user-friendly, allowing you to view images from the dataset and provide descriptions.</p>
53
+ </section>
54
+
55
+ <section>
56
+ <h2>How to Label Images</h2>
57
+ <ol>
58
+ <li><strong>Login:</strong> Use the login button at the top to login with your Hugging Face Account.</li>
59
+ <li><strong>Start Labeling:</strong> Click the 'Start Labeling' button to begin.</li>
60
+ <li><strong>View Image:</strong> An image from the GlitchBench dataset will be displayed.</li>
61
+ <li><strong>Describe the Image:</strong> Write a brief description about what is wrong or unusual about the image, focusing on the strange/unusual aspect. The description should be brief and concise.</li>
62
+ <li><strong>Submit:</strong> Click 'Submit' to save your description. You can also use 'I Don't Know' if you can't spot the bug or unusual part of the image, or 'Skip' if you don't want to provide a description for the given image.</li>
63
+ <li><strong>Continue:</strong> Move on to the next image and repeat the process.</li>
64
+ </ol>
65
+ </section>
66
+
67
+
68
+ <section>
69
+ <h2>Examples</h2>
70
+ <table style="width:100%">
71
+ <tr>
72
+ <th>Image</th>
73
+ <th>Sample Description</th>
74
+ <th>Image</th>
75
+ <th>Sample Description</th>
76
+ </tr>
77
+ <tr>
78
+ <td><img src="https://glitchbench.github.io/static/instructions/flying-horse.jpeg" alt="flying horse" style="width:100%; max-width:300px;"></td>
79
+ <td>"A horse floating in the air", or "A person riding a horse flying in the air"</td>
80
+ <td><img src="https://glitchbench.github.io/static/instructions/t-pose.jpeg" alt="t-pose" style="width:100%; max-width:300px;"></td>
81
+ <td>"A character performing a T-pose"</td>
82
+ </tr>
83
+ <tr>
84
+ <td><img src="https://glitchbench.github.io/static/instructions/a-dog-clipping-with-door.webp" alt="dog in the door" style="width:100%; max-width:300px;"></td>
85
+ <td>"A dog is clipping through the door"</td>
86
+ <td><img src="https://glitchbench.github.io/static/instructions/low-poly-face.avif" alt="low-poly face" style="width:100%; max-width:300px;"></td>
87
+ <td>"A person with a low-poly face"</td>
88
+ </tr>
89
+ <tr>
90
+ <td><img src="https://glitchbench.github.io/static/instructions/unnatural-hand-position.jpeg" alt="unnatural hands" style="width:100%; max-width:300px;"></td>
91
+ <td>"A person with unnatural hand positions."</td>
92
+ <td><img src="https://glitchbench.github.io/static/instructions/stretched_neck.jpeg" alt="unnatural neck" style="width:100%; max-width:300px;"></td>
93
+ <td>"A person with a stretched neck."</td>
94
+ </tr>
95
+ </table>
96
+ </section>
97
+
98
+
99
+ </div>
100
+ """
101
+
102
+
103
  if not JSON_DATASET_DIR.exists():
104
  JSON_DATASET_DIR.mkdir()
105
 
 
197
 
198
  with gr.Blocks() as demo:
199
  gr.Markdown("## GlitchBench Dataset Labeling Tool")
200
+ gr.Markdown("Help us to improve our GlitchBench dataset.")
201
+
202
+ with gr.Accordion("Instructions"):
203
+ gr.HTML(INSTRUCTIONS)
204
 
205
  with gr.Row():
206
  username_label = gr.Text(label="Username", interactive=False)
 
211
 
212
  username_label.attach_load_event(set_username, None)
213
 
 
 
 
214
  with gr.Row():
215
+ with gr.Column(scale=5, min_width=500):
216
+ glitch_image = gr.Image(label="Image")
217
+ glitch_image_id = gr.Textbox(label="Image ID", visible=False)
218
+ with gr.Column(scale=3, min_width=200):
219
+ user_description = gr.Textbox(lines=5, label="Description")
220
+ submit_btn = gr.Button(SUBMIT_MESSAGE)
221
+ idunnu_btn = gr.Button(IDUNNU_MESSAGE)
222
+ skip_btn = gr.Button(SKIP_MESSAGE)
223
 
224
  remaining_batch = gr.State()
225
 
 
231
  outputs=[glitch_image, glitch_image_id, user_description],
232
  )
233
 
234
+ submit_btn.click(
235
  write_user_description,
236
+ inputs=[username_label, glitch_image_id, user_description, submit_btn],
237
  outputs=[],
238
  ).then(
239
  show_random_sample,
 
241
  outputs=[glitch_image, glitch_image_id, user_description],
242
  )
243
 
244
+ idunnu_btn.click(
245
  write_user_description,
246
+ inputs=[username_label, glitch_image_id, user_description, idunnu_btn],
247
  outputs=[],
248
  ).then(
249
  show_random_sample,