Commit ·
e7571b2
1
Parent(s): 40fd53e
added depth_map
Browse files- handler.py +1 -0
- test_hf.py +15 -15
handler.py
CHANGED
|
@@ -12,6 +12,7 @@ class EndpointHandler:
|
|
| 12 |
def __init__(self, path=""):
|
| 13 |
# Load model and processor
|
| 14 |
self.model_path = path or os.environ.get("MODEL_PATH", "")
|
|
|
|
| 15 |
self.image_processor = AutoImageProcessor.from_pretrained(self.model_path)
|
| 16 |
self.model = AutoModelForDepthEstimation.from_pretrained(self.model_path)
|
| 17 |
|
|
|
|
| 12 |
def __init__(self, path=""):
|
| 13 |
# Load model and processor
|
| 14 |
self.model_path = path or os.environ.get("MODEL_PATH", "")
|
| 15 |
+
print(self.model_path)
|
| 16 |
self.image_processor = AutoImageProcessor.from_pretrained(self.model_path)
|
| 17 |
self.model = AutoModelForDepthEstimation.from_pretrained(self.model_path)
|
| 18 |
|
test_hf.py
CHANGED
|
@@ -6,8 +6,8 @@ from PIL import Image
|
|
| 6 |
import io
|
| 7 |
|
| 8 |
# URL del endpoint proporcionado por Hugging Face
|
| 9 |
-
|
| 10 |
-
ENDPOINT_URL = os.environ.get("ENDPOINT_URL", "")
|
| 11 |
# Token de API de Hugging Face
|
| 12 |
# API_TOKEN = "hf_..."
|
| 13 |
API_TOKEN = os.environ.get("API_TOKEN", "")
|
|
@@ -17,28 +17,28 @@ headers = {
|
|
| 17 |
}
|
| 18 |
|
| 19 |
# Cargar y codificar una imagen
|
| 20 |
-
image = Image.open("mine.jpeg")
|
| 21 |
-
buffered = io.BytesIO()
|
| 22 |
-
image.save(buffered, format="JPEG")
|
| 23 |
-
img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
|
| 24 |
|
| 25 |
# Preparar los datos para la solicitud
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# payload = {
|
| 27 |
# "inputs" : {
|
| 28 |
#
|
| 29 |
# },
|
| 30 |
-
# "
|
| 31 |
# "visualization": True
|
| 32 |
# }
|
| 33 |
|
| 34 |
-
payload = {
|
| 35 |
-
"inputs" : {
|
| 36 |
-
|
| 37 |
-
},
|
| 38 |
-
"file" : img_str,
|
| 39 |
-
"visualization": True
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
# Enviar la solicitud
|
| 43 |
response = requests.post(ENDPOINT_URL, headers=headers, json=payload)
|
| 44 |
|
|
|
|
| 6 |
import io
|
| 7 |
|
| 8 |
# URL del endpoint proporcionado por Hugging Face
|
| 9 |
+
ENDPOINT_URL = "https://xeagnn3ecuk0ol15.us-east-1.aws.endpoints.huggingface.cloud"
|
| 10 |
+
# ENDPOINT_URL = os.environ.get("ENDPOINT_URL", "")
|
| 11 |
# Token de API de Hugging Face
|
| 12 |
# API_TOKEN = "hf_..."
|
| 13 |
API_TOKEN = os.environ.get("API_TOKEN", "")
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
# Cargar y codificar una imagen
|
| 20 |
+
# image = Image.open("mine.jpeg")
|
| 21 |
+
# buffered = io.BytesIO()
|
| 22 |
+
# image.save(buffered, format="JPEG")
|
| 23 |
+
# img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
|
| 24 |
|
| 25 |
# Preparar los datos para la solicitud
|
| 26 |
+
payload = {
|
| 27 |
+
"inputs" : {
|
| 28 |
+
|
| 29 |
+
},
|
| 30 |
+
"url" : "https://images.unsplash.com/photo-1586023492125-27b2c045efd7?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW50ZXJpb3IlMjBkZXNpZ258ZW58MHx8MHx8fDA%3D",
|
| 31 |
+
"visualization": False
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
# payload = {
|
| 35 |
# "inputs" : {
|
| 36 |
#
|
| 37 |
# },
|
| 38 |
+
# "file" : img_str,
|
| 39 |
# "visualization": True
|
| 40 |
# }
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Enviar la solicitud
|
| 43 |
response = requests.post(ENDPOINT_URL, headers=headers, json=payload)
|
| 44 |
|