Spaces:
Running
Running
Update pages/Entorno de Ejecución.py
Browse files
pages/Entorno de Ejecución.py
CHANGED
@@ -50,8 +50,8 @@ headers = {"Authorization": f"Bearer {st.secrets['token']}"}
|
|
50 |
|
51 |
def query(data, model_name): #HF API
|
52 |
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
53 |
-
|
54 |
-
|
55 |
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
56 |
return response.json() #.json
|
57 |
|
@@ -175,12 +175,11 @@ with vit:
|
|
175 |
with st.spinner('Cargando predicción...'):
|
176 |
|
177 |
api_result = query(uploaded_file.read(), model_dict[model_choice[0]])
|
178 |
-
st.write(api_result)
|
179 |
|
180 |
-
classifiers = [pipeline("image-classification", model= model_dict[model_choice[i]]) for i in range(len(model_choice))]
|
181 |
|
182 |
#classifier = pipeline("image-classification", model= model_dict[model_choice[0]])
|
183 |
-
img = preprocess(uploaded_file, module = 'pil')
|
184 |
|
185 |
|
186 |
def vit_ensemble(classifier_list, img):
|
@@ -191,7 +190,15 @@ with vit:
|
|
191 |
if clase['label'] == 'Patacon-True':
|
192 |
y_gorrito += clase["score"]
|
193 |
return y_gorrito / len(classifier_list)
|
|
|
|
|
|
|
194 |
|
|
|
|
|
|
|
|
|
|
|
195 |
#classifier = classifier(img)
|
196 |
|
197 |
#for clase in classifier:
|
@@ -201,7 +208,7 @@ with vit:
|
|
201 |
#y_gorrito = classifier[0]["score"]
|
202 |
|
203 |
|
204 |
-
y_gorrito = vit_ensemble(classifiers, img)
|
205 |
|
206 |
if round(float(y_gorrito*100)) >= threshold:
|
207 |
st.success("¡Patacón Detectado!")
|
|
|
50 |
|
51 |
def query(data, model_name): #HF API
|
52 |
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
53 |
+
with st.spinner("Cargando Predicción... (si se demora un poco, es probable que esté cargando el modelo)"):
|
54 |
+
while "error" in response.json():
|
55 |
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
56 |
return response.json() #.json
|
57 |
|
|
|
175 |
with st.spinner('Cargando predicción...'):
|
176 |
|
177 |
api_result = query(uploaded_file.read(), model_dict[model_choice[0]])
|
|
|
178 |
|
179 |
+
#classifiers = [pipeline("image-classification", model= model_dict[model_choice[i]]) for i in range(len(model_choice))]
|
180 |
|
181 |
#classifier = pipeline("image-classification", model= model_dict[model_choice[0]])
|
182 |
+
#img = preprocess(uploaded_file, module = 'pil')
|
183 |
|
184 |
|
185 |
def vit_ensemble(classifier_list, img):
|
|
|
190 |
if clase['label'] == 'Patacon-True':
|
191 |
y_gorrito += clase["score"]
|
192 |
return y_gorrito / len(classifier_list)
|
193 |
+
|
194 |
+
|
195 |
+
y_gorrito = 0
|
196 |
|
197 |
+
for model in model_choice:
|
198 |
+
api_result = query(uploaded_file.read(), model_dict[model])
|
199 |
+
y_gorrito += api_result[1]["score"]
|
200 |
+
y_gorrito /= len(model_choice)
|
201 |
+
|
202 |
#classifier = classifier(img)
|
203 |
|
204 |
#for clase in classifier:
|
|
|
208 |
#y_gorrito = classifier[0]["score"]
|
209 |
|
210 |
|
211 |
+
#y_gorrito = vit_ensemble(classifiers, img)
|
212 |
|
213 |
if round(float(y_gorrito*100)) >= threshold:
|
214 |
st.success("¡Patacón Detectado!")
|