File size: 1,918 Bytes
90425de
 
 
 
 
 
 
b1c2932
 
 
 
 
 
7a079bf
 
90425de
55f9cc5
b1c2932
 
55f9cc5
055ff97
 
 
736a746
 
a9feac1
55f9cc5
 
736a746
b1c2932
72be8ef
b1c2932
 
7a079bf
 
b1c2932
 
 
90425de
7a079bf
b1c2932
 
 
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
import os
PATH = '/data/' # at least 150GB storage needs to be attached
os.environ['TRANSFORMERS_CACHE'] = PATH
os.environ['HF_HOME'] = PATH
os.environ['HF_DATASETS_CACHE'] = PATH
os.environ['TORCH_HOME'] = PATH

import gradio as gr

from interfaces.cap import demo as cap_demo
from interfaces.manifesto import demo as manifesto_demo
from interfaces.sentiment import demo as sentiment_demo
from interfaces.emotion import demo as emotion_demo
from interfaces.ner import demo as ner_demo
from interfaces.ner import download_models as download_spacy_models
from utils import download_hf_models

with gr.Blocks() as demo:
    gr.Markdown(
        f"""
        <style>
        @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400';
        </style>
        <div style="display: block; text-align: left; padding:0; margin:0;font-family: "Source Sans Pro", Helvetica, sans-serif;">
            <h1 style="text-align: center;font-size: 17pt;">Babel Machine Demo</h1>
            <p style="font-size: 14pt;">This is a demo for text classification using language models finetuned on data labeled by <a href="https://www.comparativeagendas.net/">CAP</a>, <a href="https://manifesto-project.wzb.eu/">Manifesto Project</a>, sentiment, emotion coding and Named Entity Recognition systems.<br>
            For the coding of complete datasets, please visit the official <a href="https://babel.poltextlab.com/">Babel Machine</a> site.<br>
            Please note that named entity inputs are case sensitive.<br>
            </p>
        </div>
        """)

    gr.TabbedInterface(
        interface_list=[cap_demo, manifesto_demo, sentiment_demo, emotion_demo, ner_demo],
        tab_names=["CAP", "Manifesto", "Sentiment (3)", "Emotions (8)", "Named Entity Recognition"],
    )

if __name__ == "__main__":
    download_hf_models()
    download_spacy_models()
    demo.launch()

# TODO: add all languages & domains