File size: 2,889 Bytes
ad75dbd
4692434
3be88b5
4692434
ad75dbd
3be88b5
 
 
a460ebb
3be88b5
a460ebb
2919eda
 
 
3be88b5
 
 
4692434
3be88b5
4692434
 
 
 
ea95eb4
12a7760
3be88b5
4692434
 
ec0a583
12a7760
 
 
 
 
ec0a583
 
3850540
 
ec0a583
4692434
 
 
 
 
 
 
 
78e855b
 
4692434
5ec754d
4692434
 
603a2e2
4692434
 
 
ea95eb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st
import pandas as pd
import utils
import time

from transformers import pipeline
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification

#####################

model_berto='hackathon-somos-nlp-2023/DiagTrast-Berto'
tokenizer_berto = AutoTokenizer.from_pretrained(model_berto)
classifier_berto = pipeline("text-classification", model=model_berto)

#####################

st.title('🏥 Diagnóstico de Trastornos Mentales')

DemoTab, AboutTab = st.tabs(["Demo", "Acerca de"])

with DemoTab:
    with st.form(key="diagtrast_form"):
        sintomas = st.text_input(label = 'Introduce texto:',
                                 value = 'El paciente tiene problemas con el alohol. Normalmente toma decisiones importantes sin pensarlo profundamente. Tiene una idea pesimista de su persona y acude a sus familiares para sentirse mejor. No tiene la capacidad de controlar sus sentimientos, la mayoría de las veces los reprime.')

        submit_button = st.form_submit_button(label="Clasificar")

    with st.form(key="examples"):
        st.markdown("<b> Ejemplos </b>")
        st.markdown("Se muestra impasivo emocionalmente.")
        st.markdown("Irresponsable en su trabajo, suele saltarse las normas. No le importa la opinión de los demás.")
        st.markdown("No puede controlar su ira.")
        

    if ex_1:
        sintomas = st.text_input(label = 'Introduce texto:',
                                 value = ex_1)

    if submit_button and not sintomas:
        st.warning("⚠️ Debe introducir los síntomas.")
        
    elif submit_button:  
        with st.spinner('Clasificando...'):
            pred_berto = classifier_berto.predict(utils.clean_text(sintomas))
            
            df = pd.DataFrame({
                'Modelo': ["DiagTrast-Berto"],
                'Diagnóstico': [pred_berto[0]['label']]
            })

        st.markdown("### Resultados:")
        st.caption("")

        st.dataframe(df, use_container_width=True)
        st.caption("")
        alert = st.success("✅ ¡Hecho!")

with AboutTab:
    st.subheader("Motivación")
    st.markdown(
        "[Colocar aquí la motivación]."
    )

    st.subheader("Recursos")
    st.markdown("""
        Modelos usados:
        - [hackathon-somos-nlp-2023/DiagTrast-Berto](https://huggingface.co/hackathon-somos-nlp-2023/DiagTrast-Berto)
        
        Dataset:
        - [hackathon-somos-nlp-2023/DiagTrast](https://huggingface.co/datasets/hackathon-somos-nlp-2023/DiagTrast)
    """)

    st.subheader("Equipo")
    st.markdown("""
        - [Alberto Martín Garrido](https://huggingface.co/Stremie)
        - [Edgar Mencia](https://huggingface.co/edmenciab)
        - [Miguel Ángel Solís Orozco](https://huggingface.co/homosapienssapiens)
        - [Jose Carlos Vílchez Villegas](https://huggingface.co/JCarlos)
    """)