Spaces:
Sleeping
Sleeping
Added code blocks
Browse files
app.py
CHANGED
@@ -387,14 +387,14 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="PEEB") as demo:
|
|
387 |
gt_class = gr.State("")
|
388 |
|
389 |
with gr.Column():
|
390 |
-
title_text = gr.Markdown("# A classifier with Part-based Explainable and Editable Bottleneck (PEEB)
|
391 |
-
gr.Markdown("Here is a PEEB bird classifier pre-trained on Bird-11K and finetuned on CUB-200 (see our [NAACL 2024 paper](https://arxiv.org/abs/2403.05297) and [code](https://github.com/anguyen8/peeb/tree/inspect_ddp)).\n This demo shows how to run PEEB on an existing image and edit
|
392 |
gr.Markdown(
|
393 |
"""
|
394 |
Steps:
|
395 |
-
1. **Select an image**. Then, PEEB will show its grounded explanations and the top-1 predicted label with associated softmax confidence score.
|
396 |
2. **Hover mouse over text descriptors** to see the corresponding region used to match to each text descriptor.
|
397 |
-
3. **Edit the text under [Extra class]()** which correspond to one extra, new class (i.e. 200+1 = 201). Further editing will overwrite this class' descriptors.
|
398 |
4. **Click on Predict** to see the grounded explanations and the top-1 label for the newly modified CUB-201 classifier.
|
399 |
"""
|
400 |
)
|
@@ -404,7 +404,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="PEEB") as demo:
|
|
404 |
|
405 |
gr.Markdown("## Select an image to start!")
|
406 |
image_gallery = gr.Gallery(value=IMAGE_GALLERY, label=None, preview=False, allow_preview=False, columns=10, height=250)
|
407 |
-
gr.Markdown("### Extra-class descriptors: \n The first row should be
|
|
|
408 |
|
409 |
with gr.Row():
|
410 |
with gr.Column():
|
@@ -419,7 +420,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="PEEB") as demo:
|
|
419 |
xclip_explanation = gr.HTML()
|
420 |
|
421 |
with gr.Column():
|
422 |
-
# xclip_edit_button = gr.Button(label="Edit", value="Reset
|
423 |
xclip_edit_button = gr.Button(value="Reset Descriptions")
|
424 |
custom_pred_label = gr.Markdown(
|
425 |
"### Extra class:"
|
|
|
387 |
gt_class = gr.State("")
|
388 |
|
389 |
with gr.Column():
|
390 |
+
title_text = gr.Markdown("# Demo | A classifier with Part-based Explainable and Editable Bottleneck (PEEB)")
|
391 |
+
gr.Markdown("Here is a PEEB bird classifier pre-trained on Bird-11K and finetuned on CUB-200 (see our [NAACL 2024 paper](https://arxiv.org/abs/2403.05297) and [code](https://github.com/anguyen8/peeb/tree/inspect_ddp)).\n This **interactive** demo shows how to run PEEB on an existing image and **edit** a class' textual description to update the classifier to detect one new bird species (without any re-training).")
|
392 |
gr.Markdown(
|
393 |
"""
|
394 |
Steps:
|
395 |
+
1. **Select an image**. Then, PEEB will show its grounded explanations and the top-1 predicted label with associated `softmax` confidence score.
|
396 |
2. **Hover mouse over text descriptors** to see the corresponding region used to match to each text descriptor.
|
397 |
+
3. **Edit the text under [Extra class]()** which correspond to one extra, new class (i.e. 200+1 = `201`). Further editing will overwrite this class' descriptors.
|
398 |
4. **Click on Predict** to see the grounded explanations and the top-1 label for the newly modified CUB-201 classifier.
|
399 |
"""
|
400 |
)
|
|
|
404 |
|
405 |
gr.Markdown("## Select an image to start!")
|
406 |
image_gallery = gr.Gallery(value=IMAGE_GALLERY, label=None, preview=False, allow_preview=False, columns=10, height=250)
|
407 |
+
gr.Markdown("### Extra-class descriptors: \n The first row should be `class name: {some name};`, the name of your 201th class. \n For the 12 part descriptors, please use `;` to separate the descriptions for each part, and use the format `{part name}: {descriptions}`."
|
408 |
+
gr.Markdown("**Note:** you can delete a row for any given part (e.g. `nape`) and that part will be removed from all 201 classes in the classifier. For example, you can edit PEEB into a classifier that only identifies birds using 5 parts by deleting all rows corresponding to the other 7 parts.")
|
409 |
|
410 |
with gr.Row():
|
411 |
with gr.Column():
|
|
|
420 |
xclip_explanation = gr.HTML()
|
421 |
|
422 |
with gr.Column():
|
423 |
+
# xclip_edit_button = gr.Button(label="Edit", value="Reset Extra-class descriptors")
|
424 |
xclip_edit_button = gr.Button(value="Reset Descriptions")
|
425 |
custom_pred_label = gr.Markdown(
|
426 |
"### Extra class:"
|