Views
No views yet
feature-extraction task on 🤗Inference endpoint.custom task for feature-extraction for 🤗 Inference Endpoints. The code for the customized pipeline is in the pipeline.py.
To use deploy this model a an Inference Endpoint you have to select Custom as task to use the pipeline.py file. -> double check if it is selected1{
2 "image": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgICAgMC....", // base64 image as bytes
3}requests.!wget https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg1import json
2from typing import List
3import requests as r
4import base64
5ENDPOINT_URL = ""
6HF_TOKEN = ""
7def predict(path_to_image: str = None):
8 with open(path_to_image, "rb") as i:
9 b64 = base64.b64encode(i.read())
10 payload = {"inputs": {"image": b64.decode("utf-8")}}
11 response = r.post(
12 ENDPOINT_URL, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload
13 )
14 return response.json()
15prediction = predict(
16 path_to_image="palace.jpg"
17)1{'feature_vector': [0.016450975090265274,
2 -0.5551009774208069,
3 0.39800673723220825,
4 -0.6809228658676147,
5 2.053842782974243,
6 -0.4712907075881958,...]
7 }