Spaces:
Runtime error
Runtime error
File size: 1,460 Bytes
597bf7d f259527 9556889 597bf7d 4c13f39 9556889 597bf7d 4c13f39 597bf7d 4c13f39 597bf7d f259527 9556889 597bf7d 9556889 597bf7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from dataclasses import dataclass
from typing import Any
import pandas as pd
from datasets import Dataset # type: ignore
from sentence_transformers import SentenceTransformer
from transformers import AutoModelForSequenceClassification # type: ignore
from transformers import AutoTokenizer # type: ignore
@dataclass
class Context:
"""This object facilitates passing around the application's state between different pages."""
model: AutoModelForSequenceClassification
tokenizer: AutoTokenizer
sentence_encoder: SentenceTransformer
tags: Any
df: pd.DataFrame
df_tokens: pd.DataFrame
df_tokens_cleaned: pd.DataFrame
df_tokens_merged: pd.DataFrame
split_sample_size: int
ds_name: str
ds_config_name: str
ds_split_name: str
split: Dataset
labels: list[str]
class Page:
"""This class encapsulates the logic for a single page of the application."""
name: str
"""The page's name that will be used in the sidebar menu."""
icon: str
"""The page's icon that will be used in the sidebar menu."""
def _get_widget_defaults(self):
"""This function holds the default settings for all widgets contained on this page.
Returns:
dict: A dictionary of widget defaults, where the keys are the widget names and the values are the default.
"""
return {}
def render(self, context):
"""This function renders the page."""
...
|