Spaces:
Running
Running
Update pages/Entorno de Ejecución.py
Browse files- pages/Entorno de Ejecución.py +17 -18
pages/Entorno de Ejecución.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
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 |
import os
|
7 |
import cv2
|
@@ -131,6 +131,14 @@ with vit:
|
|
131 |
with col_a:
|
132 |
st.title('Visual Transformers')
|
133 |
st.caption('One class is all you need!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
uploaded_file = st.file_uploader(key = 'ViT_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
135 |
flag = False
|
136 |
threshold = st.slider('¿Cuál va a ser el límite desde donde se considere patacón? (se recomienda por encima del 80%)', 0, 100, 80, key = 'threshold_vit')
|
@@ -138,9 +146,11 @@ with vit:
|
|
138 |
with col_b:
|
139 |
|
140 |
if st.button(key = 'ViT_button', label ='¿Hay un patacón en la imagen?'):
|
141 |
-
if
|
|
|
|
|
142 |
with st.spinner('Cargando predicción...'):
|
143 |
-
classifier = pipeline("image-classification", model=
|
144 |
img = preprocess(uploaded_file, module = 'pil')
|
145 |
|
146 |
classifier = classifier(img)
|
@@ -165,24 +175,15 @@ with vit:
|
|
165 |
with zero_shot:
|
166 |
|
167 |
col_a, col_b = st.columns(2)
|
168 |
-
|
169 |
with col_a:
|
170 |
|
171 |
st.title("Clasificación Zero-Shot")
|
172 |
-
st.caption("Usando Clip de OpenAI
|
173 |
|
174 |
labels_for_classification = ["A yellow deep fried smashed plantain",
|
175 |
"Fried food",
|
176 |
"Anything"]
|
177 |
-
|
178 |
-
|
179 |
-
model_dict = {
|
180 |
-
'Clip (openai/clip-vit-large-patch14-336)' : 'frncscp/patacoptimus-prime',
|
181 |
-
'Convnext (facebook/convnext-large-224)' : 'frncscp/pataconxt'
|
182 |
-
}
|
183 |
-
|
184 |
-
model_choice = st.multiselect("Seleccione uno o varios modelos de clasificación", model_dict.keys(), key = 'zs_multiselect')
|
185 |
-
|
186 |
|
187 |
uploaded_file = st.file_uploader(key = 'ZS_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
188 |
threshold = st.slider('¿Cuál va a ser el límite desde donde se considere patacón? (se recomienda por encima del 33.33%)', 0, 100, 34, key = 'threshold_ZS')
|
@@ -191,12 +192,10 @@ with zero_shot:
|
|
191 |
|
192 |
|
193 |
if st.button(key = 'ZS_button', label ='¿Hay un patacón en la imagen?'):
|
194 |
-
if
|
195 |
-
print('Recuerda seleccionar un solo modelo de clasificación')
|
196 |
-
elif uploaded_file is not None:
|
197 |
if not zsloaded:
|
198 |
with st.spinner("Cargando modelo de clasificación..."):
|
199 |
-
classifier = pipeline("zero-shot-image-classification", model =
|
200 |
zsloaded = True
|
201 |
with st.spinner('Cargando predicción...'):
|
202 |
img = preprocess(uploaded_file, module = 'pil')
|
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
3 |
from tensorflow.keras.models import load_model
|
4 |
+
from transformers import AutoConfig, AutoModel, pipeline
|
5 |
from PIL import Image
|
6 |
import os
|
7 |
import cv2
|
|
|
131 |
with col_a:
|
132 |
st.title('Visual Transformers')
|
133 |
st.caption('One class is all you need!')
|
134 |
+
|
135 |
+
model_dict = {
|
136 |
+
'google/vit-base-patch16-224-in21k' : 'frncscp/patacoptimus-prime',
|
137 |
+
'facebook/convnext-large-224' : 'frncscp/pataconxt'
|
138 |
+
}
|
139 |
+
|
140 |
+
model_choice = st.multiselect("Seleccione un modelo de clasificación", model_dict.keys(), key = 'ViT_multiselect')
|
141 |
+
|
142 |
uploaded_file = st.file_uploader(key = 'ViT_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
143 |
flag = False
|
144 |
threshold = st.slider('¿Cuál va a ser el límite desde donde se considere patacón? (se recomienda por encima del 80%)', 0, 100, 80, key = 'threshold_vit')
|
|
|
146 |
with col_b:
|
147 |
|
148 |
if st.button(key = 'ViT_button', label ='¿Hay un patacón en la imagen?'):
|
149 |
+
if len(model_choice) != 1:
|
150 |
+
print('Recuerda seleccionar un solo modelo de clasificación')
|
151 |
+
elif uploaded_file is not None:
|
152 |
with st.spinner('Cargando predicción...'):
|
153 |
+
classifier = pipeline("image-classification", model= model_dict[model_choice[0]])
|
154 |
img = preprocess(uploaded_file, module = 'pil')
|
155 |
|
156 |
classifier = classifier(img)
|
|
|
175 |
with zero_shot:
|
176 |
|
177 |
col_a, col_b = st.columns(2)
|
178 |
+
|
179 |
with col_a:
|
180 |
|
181 |
st.title("Clasificación Zero-Shot")
|
182 |
+
st.caption("Usando Clip de OpenAI")
|
183 |
|
184 |
labels_for_classification = ["A yellow deep fried smashed plantain",
|
185 |
"Fried food",
|
186 |
"Anything"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
uploaded_file = st.file_uploader(key = 'ZS_upload', label = 'Sube la imagen a clasificar',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
|
189 |
threshold = st.slider('¿Cuál va a ser el límite desde donde se considere patacón? (se recomienda por encima del 33.33%)', 0, 100, 34, key = 'threshold_ZS')
|
|
|
192 |
|
193 |
|
194 |
if st.button(key = 'ZS_button', label ='¿Hay un patacón en la imagen?'):
|
195 |
+
if uploaded_file is not None:
|
|
|
|
|
196 |
if not zsloaded:
|
197 |
with st.spinner("Cargando modelo de clasificación..."):
|
198 |
+
classifier = pipeline("zero-shot-image-classification", model = 'openai/clip-vit-large-patch14-336')
|
199 |
zsloaded = True
|
200 |
with st.spinner('Cargando predicción...'):
|
201 |
img = preprocess(uploaded_file, module = 'pil')
|