fix inputs
Browse filesFiles changed (3)
31 unmodified lines32333435363738394031 unmodified linesA :obj:`list` | `dict`: will be serialized and returned"""# get inputsprompt = data.pop("prompt", data)# get additional date field0image_url = data.pop("files", None)[-1]['path']print(image_url)print(prompt)31 unmodified lines3233343536373839404131 unmodified linesA :obj:`list` | `dict`: will be serialized and returned"""# get inputsinputs = data.pop("inputs", data)# get additional date field0prompt = inputs.pop("prompt", None)[-1]['path']image_url = inputs.pop("files", None)[-1]['path']print(image_url)print(prompt)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import osimport requestsfrom dotenv import load_dotenv
load_dotenv()
# globalTOKEN =os.environ.get('HF_ACCESS_TOKEN')URL = "https://ojcld767sjuhadix.us-east-1.aws.endpoints.huggingface.cloud"headers = {"Authorization": f"Bearer {TOKEN}"}
# prepare sample payloadprompt = "Can you describe this picture focusing on specifics visual artifacts and ambiance (objects, colors, person, athmosphere..). Please stay concise only output keywords and concepts detected."files = [ {"path": "https://media.rolex.com/image/upload/q_auto/f_auto/c_limit,w_2440/v1708384234/rolexcom/about-rolex/hub/about-rolex-hub-cover-aca202310cw-0002-portrait"}]
def call(payload): response = requests.post( URL, headers=headers, json=payload ) return response.json()
def test_local(payload): from handler import EndpointHandler
# init handler my_handler = EndpointHandler(path=".") my_handler(payload)
payload = { "inputs": { "prompt": prompt, "files": files }}
# out_local = test_local(payload)# print(out_local)
out = call(payload)print(out)__pycache__/handler.cpython-311.pycAdded
handler.py+3-2
test_inference_endpoint.pyAdded+46