frncscp commited on
Commit
5c94fdc
1 Parent(s): 490112d

Update pages/Entorno de Ejecución.py

Browse files
Files changed (1) hide show
  1. pages/Entorno de Ejecución.py +11 -1
pages/Entorno de Ejecución.py CHANGED
@@ -6,6 +6,7 @@ from PIL import Image
6
  import os
7
  import cv2
8
  import numpy as np
 
9
 
10
  st.set_page_config(
11
  page_title = 'Patacotrón',
@@ -44,6 +45,15 @@ def multiclass_prediction(classifier, important_class): #made for hf zero-shot p
44
  class_score = clase['score']
45
  return (labels[0] if len(labels) == 1 else labels, score, class_score)
46
 
 
 
 
 
 
 
 
 
 
47
  @st.cache_resource
48
  def load_clip():
49
  classifier = pipeline("zero-shot-image-classification", model = 'openai/clip-vit-large-patch14-336')
@@ -185,7 +195,7 @@ with vit:
185
  # y_gorrito = clase["score"]
186
 
187
  #y_gorrito = classifier[0]["score"]
188
-
189
  y_gorrito = vit_ensemble(classifiers, img)
190
 
191
  if round(float(y_gorrito*100)) >= threshold:
 
6
  import os
7
  import cv2
8
  import numpy as np
9
+ import requests
10
 
11
  st.set_page_config(
12
  page_title = 'Patacotrón',
 
45
  class_score = clase['score']
46
  return (labels[0] if len(labels) == 1 else labels, score, class_score)
47
 
48
+ API_URL = "https://api-inference.huggingface.co/models"
49
+ headers = {"Authorization": f"Bearer {token}"}
50
+
51
+ def query(filename, model_name): #HF API
52
+ with open(filename, "rb") as f:
53
+ data = f.read()
54
+ response = requests.post(API_URL + / + model_name', headers=headers, data=data)
55
+ return response.json #.json
56
+
57
  @st.cache_resource
58
  def load_clip():
59
  classifier = pipeline("zero-shot-image-classification", model = 'openai/clip-vit-large-patch14-336')
 
195
  # y_gorrito = clase["score"]
196
 
197
  #y_gorrito = classifier[0]["score"]
198
+ api_result = query(img, model_choice[0])
199
  y_gorrito = vit_ensemble(classifiers, img)
200
 
201
  if round(float(y_gorrito*100)) >= threshold: