Spaces:
Running
Running
Update pages/Entorno de Ejecución.py
Browse files
pages/Entorno de Ejecución.py
CHANGED
@@ -2,8 +2,7 @@ import streamlit as st
|
|
2 |
import tensorflow as tf
|
3 |
from tensorflow.keras.models import load_model
|
4 |
from transformers import pipeline
|
5 |
-
from PIL import Image
|
6 |
-
|
7 |
import os
|
8 |
import cv2
|
9 |
import numpy as np
|
@@ -77,7 +76,8 @@ with cnn:
|
|
77 |
if module == 'cv2':
|
78 |
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
|
79 |
elif module == 'pil':
|
80 |
-
img = Image.
|
|
|
81 |
return img
|
82 |
|
83 |
# Set the image dimensions
|
@@ -86,7 +86,7 @@ with cnn:
|
|
86 |
executed = False
|
87 |
|
88 |
with col_b:
|
89 |
-
|
90 |
uploaded_file = st.file_uploader(key = 'convnet_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
91 |
|
92 |
if st.button(key = 'convnet_button', label ='¿Hay un patacón en la imagen?'):
|
@@ -96,7 +96,7 @@ with cnn:
|
|
96 |
elif uploaded_file is not None:
|
97 |
img = preprocess(uploaded_file)
|
98 |
if ultra_flag:
|
99 |
-
with st.spinner('Cargando ultra-predicción...'):
|
100 |
if not executed:
|
101 |
ultraptctrn = [load_model(model_dict[model]) for model in ultraversions]
|
102 |
executed = True
|
@@ -132,7 +132,7 @@ with iforest:
|
|
132 |
with gan:
|
133 |
st.write('Próximamente')
|
134 |
with vit:
|
135 |
-
|
136 |
col_a, col_b = st.columns(2)
|
137 |
|
138 |
with col_a:
|
@@ -141,6 +141,7 @@ with vit:
|
|
141 |
uploaded_file = st.file_uploader(key = 'ViT_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
142 |
if st.button(key = 'ViT_button', label ='¿Hay un patacón en la imagen?'):
|
143 |
if uploaded_file is not None:
|
|
|
144 |
classifier = pipeline("image-classification", model="frncscp/patacoptimus-prime")
|
145 |
img = preprocess(uploaded_file, module = 'pil')
|
146 |
raw_img = img
|
|
|
2 |
import tensorflow as tf
|
3 |
from tensorflow.keras.models import load_model
|
4 |
from transformers import pipeline
|
5 |
+
from PIL import Image
|
|
|
6 |
import os
|
7 |
import cv2
|
8 |
import numpy as np
|
|
|
76 |
if module == 'cv2':
|
77 |
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
|
78 |
elif module == 'pil':
|
79 |
+
img = Image.frombuffer(data = uploaded_file.read())
|
80 |
+
#img = Image.open(io.BytesIO(file_uploader.read()))
|
81 |
return img
|
82 |
|
83 |
# Set the image dimensions
|
|
|
86 |
executed = False
|
87 |
|
88 |
with col_b:
|
89 |
+
|
90 |
uploaded_file = st.file_uploader(key = 'convnet_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
91 |
|
92 |
if st.button(key = 'convnet_button', label ='¿Hay un patacón en la imagen?'):
|
|
|
96 |
elif uploaded_file is not None:
|
97 |
img = preprocess(uploaded_file)
|
98 |
if ultra_flag:
|
99 |
+
with st.spinner('Cargando ultra-predicción...', key = 'convspinner'):
|
100 |
if not executed:
|
101 |
ultraptctrn = [load_model(model_dict[model]) for model in ultraversions]
|
102 |
executed = True
|
|
|
132 |
with gan:
|
133 |
st.write('Próximamente')
|
134 |
with vit:
|
135 |
+
|
136 |
col_a, col_b = st.columns(2)
|
137 |
|
138 |
with col_a:
|
|
|
141 |
uploaded_file = st.file_uploader(key = 'ViT_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
142 |
if st.button(key = 'ViT_button', label ='¿Hay un patacón en la imagen?'):
|
143 |
if uploaded_file is not None:
|
144 |
+
with st.spinner('Cargando predicción...', key = 'vitspinner')
|
145 |
classifier = pipeline("image-classification", model="frncscp/patacoptimus-prime")
|
146 |
img = preprocess(uploaded_file, module = 'pil')
|
147 |
raw_img = img
|