Spaces:
Running
Running
Update pages/Entorno de Ejecución.py
Browse files
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 AutoConfig, AutoModel, pipeline
|
5 |
from PIL import Image
|
6 |
import os
|
7 |
import cv2
|
@@ -50,13 +50,15 @@ 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 |
-
|
56 |
return response.json() #.json
|
57 |
|
58 |
@st.cache_resource
|
59 |
def load_clip():
|
|
|
|
|
60 |
classifier = pipeline("zero-shot-image-classification", model = 'openai/clip-vit-large-patch14-336')
|
61 |
return classifier
|
62 |
|
|
|
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, AutoProcessor, AutoModelForZeroShotImageClassification
|
5 |
from PIL import Image
|
6 |
import os
|
7 |
import cv2
|
|
|
50 |
|
51 |
def query(data, model_name): #HF API
|
52 |
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
53 |
+
while "error" in response.json():
|
54 |
+
response = requests.post(API_URL + "/" + model_name, headers=headers, data=data)
|
55 |
+
st.write("Done.")
|
56 |
return response.json() #.json
|
57 |
|
58 |
@st.cache_resource
|
59 |
def load_clip():
|
60 |
+
#processor = AutoProcessor.from_pretrained("openai/clip-vit-large-patch14-336")
|
61 |
+
#model = AutoModelForZeroShotImageClassification.from_pretrained("openai/clip-vit-large-patch14-336")
|
62 |
classifier = pipeline("zero-shot-image-classification", model = 'openai/clip-vit-large-patch14-336')
|
63 |
return classifier
|
64 |
|