Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,60 @@
|
|
1 |
-
import
|
|
|
|
|
2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification, pipeline
|
4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
auth_token = os.environ['HF_TOKEN']
|
7 |
|
@@ -89,7 +142,7 @@ iface = gr.Interface(
|
|
89 |
title="Scoring Demo",
|
90 |
description="Autobiographical Memory Analysis: This demo combines two text - and two sequence classification models to showcase our automated Autobiographical Interview scoring method. Submit a narrative to see the results.",
|
91 |
examples =examples,
|
92 |
-
theme="soft" #monochrome
|
93 |
)
|
94 |
|
95 |
# Launch the combined interface
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
|
4 |
import gradio as gr
|
5 |
+
from gradio.themes.base import Base
|
6 |
+
from gradio.themes.utils import colors, fonts, sizes
|
7 |
+
|
8 |
+
import torch
|
9 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification, pipeline
|
10 |
import os
|
11 |
+
import time
|
12 |
+
|
13 |
+
# Helper function to convert hex to RGB tuple
|
14 |
+
def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
|
15 |
+
hex_color = hex_color.lstrip('#')
|
16 |
+
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
17 |
+
|
18 |
+
class MPGPoster(Base):
|
19 |
+
def __init__(
|
20 |
+
self,
|
21 |
+
*,
|
22 |
+
primary_hue: colors.Color | str = colors.Color(*hex_to_rgb("#f47317")),
|
23 |
+
background_hue: colors.Color | str = colors.Color(*hex_to_rgb("#f6f6f6ff")),
|
24 |
+
secondary_dark_hue: colors.Color | str = colors.Color(*hex_to_rgb("#006c66")),
|
25 |
+
secondary_light_hue: colors.Color | str = colors.Color(*hex_to_rgb("#6ad5bc")),
|
26 |
+
tertiary_highlight_hue: colors.Color | str = colors.Color(*hex_to_rgb("#fbf22c")),
|
27 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
28 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
29 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
30 |
+
font: fonts.Font
|
31 |
+
| str
|
32 |
+
| Iterable[fonts.Font | str] = (
|
33 |
+
fonts.GoogleFont("Quicksand"),
|
34 |
+
"ui-sans-serif",
|
35 |
+
"sans-serif",
|
36 |
+
),
|
37 |
+
font_mono: fonts.Font
|
38 |
+
| str
|
39 |
+
| Iterable[fonts.Font | str] = (
|
40 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
41 |
+
"ui-monospace",
|
42 |
+
"monospace",
|
43 |
+
),
|
44 |
+
):
|
45 |
+
super().__init__(
|
46 |
+
primary_hue=primary_hue,
|
47 |
+
secondary_hue=secondary_dark_hue, # Assuming secondary dark hue as main secondary
|
48 |
+
neutral_hue=background_hue, # Assuming background hue as neutral
|
49 |
+
spacing_size=spacing_size,
|
50 |
+
radius_size=radius_size,
|
51 |
+
text_size=text_size,
|
52 |
+
font=font,
|
53 |
+
font_mono=font_mono,
|
54 |
+
)
|
55 |
+
|
56 |
+
# Using the theme in a Gradio interface
|
57 |
+
mpg_poster = MPGPoster()
|
58 |
|
59 |
auth_token = os.environ['HF_TOKEN']
|
60 |
|
|
|
142 |
title="Scoring Demo",
|
143 |
description="Autobiographical Memory Analysis: This demo combines two text - and two sequence classification models to showcase our automated Autobiographical Interview scoring method. Submit a narrative to see the results.",
|
144 |
examples =examples,
|
145 |
+
theme= mpg_poster #"soft" #monochrome
|
146 |
)
|
147 |
|
148 |
# Launch the combined interface
|