Spaces:
Sleeping
Sleeping
Update pages/Entorno de Ejecución.py
Browse files- pages/Entorno de Ejecución.py +28 -27
pages/Entorno de Ejecución.py
CHANGED
|
@@ -68,31 +68,32 @@ with col_a:
|
|
| 68 |
IMAGE_WIDTH = IMAGE_HEIGHT = 224
|
| 69 |
|
| 70 |
with col_b:
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
if y_gorrito > threshold:
|
| 93 |
-
st.success("¡Patacón Detectado!")
|
| 94 |
-
else:
|
| 95 |
-
st.error("No se encontró rastro de patacón.")
|
| 96 |
-
st.caption(f'La probabilidad de que la imagen tenga un patacón es del: {round(float(y_gorrito), 2)*100}%')
|
| 97 |
-
#st.write('Si los resultados no fueron los esperados, por favor, despliga la barra lateral y entra al botón "Report a Bug"')
|
| 98 |
-
st.image(raw_img)
|
|
|
|
| 68 |
IMAGE_WIDTH = IMAGE_HEIGHT = 224
|
| 69 |
|
| 70 |
with col_b:
|
| 71 |
+
if st.button('Predecir'):
|
| 72 |
+
uploaded_file = st.file_uploader(label = '',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
| 73 |
+
|
| 74 |
+
if uploaded_file is not None:
|
| 75 |
+
# Load the image and resize it to the required dimensions
|
| 76 |
+
img = np.frombuffer(uploaded_file.read(), np.uint8)
|
| 77 |
+
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
|
| 78 |
+
raw_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 79 |
+
img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
|
| 80 |
+
|
| 81 |
+
# Convert the image to RGB and preprocess it for the model
|
| 82 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 83 |
+
img = img / 255.
|
| 84 |
+
|
| 85 |
+
# Pass the image to the model and get the prediction
|
| 86 |
+
if ultra_flag:
|
| 87 |
+
with st.spinner('Cargando ultra-predicción...'):
|
| 88 |
+
y_gorrito = ensemble_model(ultraptctrn, img)
|
| 89 |
+
else:
|
| 90 |
+
with st.spinner('Cargando predicción...'):
|
| 91 |
+
y_gorrito = ensemble_model(selected_models, img)
|
| 92 |
|
| 93 |
+
if y_gorrito > threshold:
|
| 94 |
+
st.success("¡Patacón Detectado!")
|
| 95 |
+
else:
|
| 96 |
+
st.error("No se encontró rastro de patacón.")
|
| 97 |
+
st.caption(f'La probabilidad de que la imagen tenga un patacón es del: {round(float(y_gorrito), 2)*100}%')
|
| 98 |
+
#st.write('Si los resultados no fueron los esperados, por favor, despliga la barra lateral y entra al botón "Report a Bug"')
|
| 99 |
+
st.image(raw_img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|