Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
import random
|
|
@@ -5,6 +7,115 @@ from datetime import datetime
|
|
| 5 |
from typing import Dict, List, Tuple
|
| 6 |
import hashlib
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
guideline = """
|
| 10 |
## Overview
|
|
@@ -322,7 +433,7 @@ custom_css = """
|
|
| 322 |
"""
|
| 323 |
|
| 324 |
# Create Gradio interface
|
| 325 |
-
with gr.Blocks(theme=
|
| 326 |
gr.Markdown("# Norwegian Fluency Annotation")
|
| 327 |
with gr.Accordion("Click here to see the full annotation guidelines:", open=False):
|
| 328 |
gr.Markdown(guideline, padding=True)
|
|
@@ -332,7 +443,7 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Source Sans Pro"
|
|
| 332 |
# Login Interface
|
| 333 |
with gr.Column(visible=True) as login_interface:
|
| 334 |
with gr.Column(variant="panel", elem_id="login-group"):
|
| 335 |
-
gr.Markdown("##
|
| 336 |
user_id_input = gr.Textbox(
|
| 337 |
label="Enter your unique annotator ID to begin",
|
| 338 |
placeholder="Annotator ID"
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
import gradio as gr
|
| 4 |
import json
|
| 5 |
import random
|
|
|
|
| 7 |
from typing import Dict, List, Tuple
|
| 8 |
import hashlib
|
| 9 |
|
| 10 |
+
from collections.abc import Iterable
|
| 11 |
+
|
| 12 |
+
from gradio.themes.base import Base
|
| 13 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Soft(Base):
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
*,
|
| 20 |
+
primary_hue: colors.Color | str = colors.indigo,
|
| 21 |
+
secondary_hue: colors.Color | str = colors.indigo,
|
| 22 |
+
neutral_hue: colors.Color | str = colors.gray,
|
| 23 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
| 24 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
| 25 |
+
text_size: sizes.Size | str = sizes.text_md,
|
| 26 |
+
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 27 |
+
fonts.LocalFont("Montserrat"),
|
| 28 |
+
"ui-sans-serif",
|
| 29 |
+
"system-ui",
|
| 30 |
+
"sans-serif",
|
| 31 |
+
),
|
| 32 |
+
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 33 |
+
fonts.LocalFont("IBM Plex Mono"),
|
| 34 |
+
"ui-monospace",
|
| 35 |
+
"Consolas",
|
| 36 |
+
"monospace",
|
| 37 |
+
),
|
| 38 |
+
):
|
| 39 |
+
super().__init__(
|
| 40 |
+
primary_hue=primary_hue,
|
| 41 |
+
secondary_hue=secondary_hue,
|
| 42 |
+
neutral_hue=neutral_hue,
|
| 43 |
+
spacing_size=spacing_size,
|
| 44 |
+
radius_size=radius_size,
|
| 45 |
+
text_size=text_size,
|
| 46 |
+
font=font,
|
| 47 |
+
font_mono=font_mono,
|
| 48 |
+
)
|
| 49 |
+
self.name = "soft"
|
| 50 |
+
super().set(
|
| 51 |
+
# Colors
|
| 52 |
+
background_fill_primary="*neutral_100",
|
| 53 |
+
slider_color="*primary_500",
|
| 54 |
+
slider_color_dark="*primary_600",
|
| 55 |
+
# Shadows
|
| 56 |
+
shadow_drop="0 1px 4px 0 rgb(0 0 0 / 0.2)",
|
| 57 |
+
shadow_drop_lg="0 2px 5px 0 rgb(0 0 0 / 0.2)",
|
| 58 |
+
# Block Labels
|
| 59 |
+
block_background_fill="white",
|
| 60 |
+
block_label_padding="*spacing_sm *spacing_md",
|
| 61 |
+
block_label_background_fill="*primary_100",
|
| 62 |
+
block_label_background_fill_dark="*primary_600",
|
| 63 |
+
block_label_radius="*radius_md",
|
| 64 |
+
block_label_text_size="*text_md",
|
| 65 |
+
block_label_text_weight="600",
|
| 66 |
+
block_label_text_color="*primary_500",
|
| 67 |
+
block_label_text_color_dark="white",
|
| 68 |
+
block_title_radius="*block_label_radius",
|
| 69 |
+
block_title_padding="*block_label_padding",
|
| 70 |
+
block_title_background_fill="*block_label_background_fill",
|
| 71 |
+
block_title_text_weight="600",
|
| 72 |
+
block_title_text_color="*primary_500",
|
| 73 |
+
block_title_text_color_dark="white",
|
| 74 |
+
block_label_margin="*spacing_md",
|
| 75 |
+
# Inputs
|
| 76 |
+
input_background_fill="white",
|
| 77 |
+
input_border_color="*neutral_100",
|
| 78 |
+
input_shadow="*shadow_drop",
|
| 79 |
+
input_shadow_focus="*shadow_drop_lg",
|
| 80 |
+
checkbox_shadow="none",
|
| 81 |
+
# Buttons
|
| 82 |
+
shadow_spread="6px",
|
| 83 |
+
button_primary_shadow="*shadow_drop_lg",
|
| 84 |
+
button_primary_shadow_hover="*shadow_drop_lg",
|
| 85 |
+
button_primary_shadow_active="*shadow_inset",
|
| 86 |
+
button_secondary_shadow="*shadow_drop_lg",
|
| 87 |
+
button_secondary_shadow_hover="*shadow_drop_lg",
|
| 88 |
+
button_secondary_shadow_active="*shadow_inset",
|
| 89 |
+
checkbox_label_shadow="*shadow_drop_lg",
|
| 90 |
+
button_primary_background_fill="*primary_500",
|
| 91 |
+
button_primary_background_fill_hover="*primary_400",
|
| 92 |
+
button_primary_background_fill_hover_dark="*primary_500",
|
| 93 |
+
button_primary_text_color="white",
|
| 94 |
+
button_secondary_background_fill="white",
|
| 95 |
+
button_secondary_background_fill_hover="*neutral_100",
|
| 96 |
+
button_secondary_background_fill_hover_dark="*primary_500",
|
| 97 |
+
button_secondary_text_color="*neutral_800",
|
| 98 |
+
button_cancel_background_fill="*button_secondary_background_fill",
|
| 99 |
+
button_cancel_background_fill_hover="*button_secondary_background_fill_hover",
|
| 100 |
+
button_cancel_background_fill_hover_dark="*button_secondary_background_fill_hover",
|
| 101 |
+
button_cancel_text_color="*button_secondary_text_color",
|
| 102 |
+
checkbox_label_background_fill_selected="*primary_500",
|
| 103 |
+
checkbox_label_background_fill_selected_dark="*primary_600",
|
| 104 |
+
checkbox_border_width="1px",
|
| 105 |
+
checkbox_border_color="*neutral_100",
|
| 106 |
+
checkbox_border_color_dark="*neutral_600",
|
| 107 |
+
checkbox_background_color_selected="*primary_600",
|
| 108 |
+
checkbox_background_color_selected_dark="*primary_700",
|
| 109 |
+
checkbox_border_color_focus="*primary_500",
|
| 110 |
+
checkbox_border_color_focus_dark="*primary_600",
|
| 111 |
+
checkbox_border_color_selected="*primary_600",
|
| 112 |
+
checkbox_border_color_selected_dark="*primary_700",
|
| 113 |
+
checkbox_label_text_color_selected="white",
|
| 114 |
+
# Borders
|
| 115 |
+
block_border_width="0px",
|
| 116 |
+
panel_border_width="0px",
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
|
| 120 |
guideline = """
|
| 121 |
## Overview
|
|
|
|
| 433 |
"""
|
| 434 |
|
| 435 |
# Create Gradio interface
|
| 436 |
+
with gr.Blocks(theme=Soft(font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial"]), title="Dataset Annotation Tool", css=custom_css) as app:
|
| 437 |
gr.Markdown("# Norwegian Fluency Annotation")
|
| 438 |
with gr.Accordion("Click here to see the full annotation guidelines:", open=False):
|
| 439 |
gr.Markdown(guideline, padding=True)
|
|
|
|
| 443 |
# Login Interface
|
| 444 |
with gr.Column(visible=True) as login_interface:
|
| 445 |
with gr.Column(variant="panel", elem_id="login-group"):
|
| 446 |
+
gr.Markdown("## Log in", padding=True)
|
| 447 |
user_id_input = gr.Textbox(
|
| 448 |
label="Enter your unique annotator ID to begin",
|
| 449 |
placeholder="Annotator ID"
|