JairoDanielMT commited on
Commit
6f605b8
verified
1 Parent(s): 80ed49d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -1,6 +1,5 @@
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")
@@ -32,7 +31,7 @@ with col3:
32
  socialSupport_emotionality = st.number_input("Social Support Emotionality", min_value=0.0, max_value=100.0, value=0.0)
33
  socialSupport_appreciation = st.number_input("Social Support Appreciation", min_value=0.0, max_value=100.0, value=0.0)
34
 
35
- # Crear el 煤ltimo campo fuera de las columnas
36
  empowerment_knowledge = st.number_input("Empowerment Knowledge", min_value=0.0, max_value=100.0, value=10.0)
37
  empowerment_abilities = st.number_input("Empowerment Abilities", min_value=0.0, max_value=100.0, value=20.0)
38
  empowerment_desires = st.number_input("Empowerment Desires", min_value=0.0, max_value=100.0, value=0.0)
@@ -56,6 +55,7 @@ if st.button("Obtener Diagn贸stico"):
56
  "motivation_willingness": motivation_willingness,
57
  "socialSupport_emotionality": socialSupport_emotionality,
58
  "socialSupport_appreciation": socialSupport_appreciation,
 
59
  "empowerment_knowledge": empowerment_knowledge,
60
  "empowerment_abilities": empowerment_abilities,
61
  "empowerment_desires": empowerment_desires
@@ -64,14 +64,20 @@ if st.button("Obtener Diagn贸stico"):
64
  # Hacer la solicitud a la API
65
  url = 'https://jairodanielmt-ejemplo-anibal.hf.space/predict/'
66
  headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
67
- response = requests.post(url, json=payload, headers=headers)
68
-
69
- # Verificar si la respuesta es exitosa
70
- if response.status_code == 200:
71
- # Mostrar el diagn贸stico recibido
 
72
  result = response.json()
 
73
  ca_cervix_prediction = result.get('ca_cervix_prediction', 'No disponible')
74
- st.write(f"Diagn贸stico: {ca_cervix_prediction}")
75
- else:
76
- # Si ocurre un error en la solicitud
77
- st.error("Ocurri贸 un error al obtener el diagn贸stico. Intenta nuevamente m谩s tarde.")
 
 
 
 
 
1
  import streamlit as st
2
  import requests
 
3
 
4
  # T铆tulo de la aplicaci贸n
5
  st.title("Predicci贸n de C谩ncer Cervical")
 
31
  socialSupport_emotionality = st.number_input("Social Support Emotionality", min_value=0.0, max_value=100.0, value=0.0)
32
  socialSupport_appreciation = st.number_input("Social Support Appreciation", min_value=0.0, max_value=100.0, value=0.0)
33
 
34
+ # Campos adicionales fuera de las columnas
35
  empowerment_knowledge = st.number_input("Empowerment Knowledge", min_value=0.0, max_value=100.0, value=10.0)
36
  empowerment_abilities = st.number_input("Empowerment Abilities", min_value=0.0, max_value=100.0, value=20.0)
37
  empowerment_desires = st.number_input("Empowerment Desires", min_value=0.0, max_value=100.0, value=0.0)
 
55
  "motivation_willingness": motivation_willingness,
56
  "socialSupport_emotionality": socialSupport_emotionality,
57
  "socialSupport_appreciation": socialSupport_appreciation,
58
+ "socialSupport_instrumental": 0, # Este campo no lo env铆as en el formulario pero lo necesitas
59
  "empowerment_knowledge": empowerment_knowledge,
60
  "empowerment_abilities": empowerment_abilities,
61
  "empowerment_desires": empowerment_desires
 
64
  # Hacer la solicitud a la API
65
  url = 'https://jairodanielmt-ejemplo-anibal.hf.space/predict/'
66
  headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
67
+
68
+ try:
69
+ response = requests.post(url, json=payload, headers=headers)
70
+ response.raise_for_status() # Lanza un error si el c贸digo de estado no es 200
71
+
72
+ # Verificar si la respuesta es exitosa
73
  result = response.json()
74
+ # Asumiendo que la respuesta contiene una clave 'ca_cervix_prediction'
75
  ca_cervix_prediction = result.get('ca_cervix_prediction', 'No disponible')
76
+
77
+ # Mostrar el diagn贸stico recibido
78
+ st.success(f"Diagn贸stico: {ca_cervix_prediction}")
79
+
80
+ except requests.exceptions.HTTPError as http_err:
81
+ st.error(f"Error HTTP: {http_err}")
82
+ except Exception as err:
83
+ st.error(f"Error: {err}")