JairoDanielMT commited on
Commit
53e09be
verified
1 Parent(s): ee6e0ac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ # T铆tulo de la aplicaci贸n
6
+ st.title("Predicci贸n de C谩ncer Cervical")
7
+
8
+ # Crear los campos de entrada para el formulario
9
+ behavior_sexualRisk = st.number_input("Risk Behavior (Sexual)", min_value=0.0, max_value=100.0, value=10.0)
10
+ behavior_eating = st.number_input("Eating Behavior", min_value=0.0, max_value=100.0, value=10.0)
11
+ behavior_personalHygine = st.number_input("Personal Hygiene", min_value=0.0, max_value=100.0, value=10.0)
12
+ intention_aggregation = st.number_input("Intention Aggregation", min_value=0.0, max_value=100.0, value=10.0)
13
+ intention_commitment = st.number_input("Intention Commitment", min_value=0.0, max_value=100.0, value=10.0)
14
+ attitude_consistency = st.number_input("Attitude Consistency", min_value=0.0, max_value=100.0, value=10.0)
15
+ attitude_spontaneity = st.number_input("Attitude Spontaneity", min_value=0.0, max_value=100.0, value=0.0)
16
+ norm_significantPerson = st.number_input("Norm Significant Person", min_value=0.0, max_value=100.0, value=0.0)
17
+ norm_fulfillment = st.number_input("Norm Fulfillment", min_value=0.0, max_value=100.0, value=0.0)
18
+ perception_vulnerability = st.number_input("Perception Vulnerability", min_value=0.0, max_value=100.0, value=0.0)
19
+ perception_severity = st.number_input("Perception Severity", min_value=0.0, max_value=100.0, value=0.0)
20
+ motivation_strength = st.number_input("Motivation Strength", min_value=0.0, max_value=100.0, value=0.34)
21
+ motivation_willingness = st.number_input("Motivation Willingness", min_value=0.0, max_value=100.0, value=0.54)
22
+ socialSupport_emotionality = st.number_input("Social Support Emotionality", min_value=0.0, max_value=100.0, value=0.0)
23
+ socialSupport_appreciation = st.number_input("Social Support Appreciation", min_value=0.0, max_value=100.0, value=0.0)
24
+ socialSupport_instrumental = st.number_input("Social Support Instrumental", min_value=0.0, max_value=100.0, value=0.0)
25
+ empowerment_knowledge = st.number_input("Empowerment Knowledge", min_value=0.0, max_value=100.0, value=10.0)
26
+ empowerment_abilities = st.number_input("Empowerment Abilities", min_value=0.0, max_value=100.0, value=20.0)
27
+ empowerment_desires = st.number_input("Empowerment Desires", min_value=0.0, max_value=100.0, value=0.0)
28
+
29
+ # Bot贸n para hacer la predicci贸n
30
+ if st.button("Obtener Diagn贸stico"):
31
+ # Crear el payload para la solicitud
32
+ payload = {
33
+ "behavior_sexualRisk": behavior_sexualRisk,
34
+ "behavior_eating": behavior_eating,
35
+ "behavior_personalHygine": behavior_personalHygine,
36
+ "intention_aggregation": intention_aggregation,
37
+ "intention_commitment": intention_commitment,
38
+ "attitude_consistency": attitude_consistency,
39
+ "attitude_spontaneity": attitude_spontaneity,
40
+ "norm_significantPerson": norm_significantPerson,
41
+ "norm_fulfillment": norm_fulfillment,
42
+ "perception_vulnerability": perception_vulnerability,
43
+ "perception_severity": perception_severity,
44
+ "motivation_strength": motivation_strength,
45
+ "motivation_willingness": motivation_willingness,
46
+ "socialSupport_emotionality": socialSupport_emotionality,
47
+ "socialSupport_appreciation": socialSupport_appreciation,
48
+ "socialSupport_instrumental": socialSupport_instrumental,
49
+ "empowerment_knowledge": empowerment_knowledge,
50
+ "empowerment_abilities": empowerment_abilities,
51
+ "empowerment_desires": empowerment_desires
52
+ }
53
+
54
+ # Hacer la solicitud a la API
55
+ url = 'https://jairodanielmt-ejemplo-anibal.hf.space/predict/'
56
+ headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
57
+ response = requests.post(url, json=payload, headers=headers)
58
+
59
+ # Verificar si la respuesta es exitosa
60
+ if response.status_code == 200:
61
+ # Mostrar el diagn贸stico recibido
62
+ result = response.json()
63
+ ca_cervix_prediction = result.get('ca_cervix_prediction', 'No disponible')
64
+ st.write(f"Diagn贸stico: {ca_cervix_prediction}")
65
+ else:
66
+ # Si ocurre un error en la solicitud
67
+ st.error("Ocurri贸 un error al obtener el diagn贸stico. Intenta nuevamente m谩s tarde.")