eBoreal commited on
Commit
6d97351
1 Parent(s): f0e2eeb

fix inputs

Browse files
__pycache__/handler.cpython-311.pyc ADDED
Binary file (4.24 kB). View file
 
handler.py CHANGED
@@ -32,9 +32,10 @@ class EndpointHandler:
32
  A :obj:`list` | `dict`: will be serialized and returned
33
  """
34
  # get inputs
35
- prompt = data.pop("prompt", data)
36
  # get additional date field0
37
- image_url = data.pop("files", None)[-1]['path']
 
38
 
39
  print(image_url)
40
  print(prompt)
 
32
  A :obj:`list` | `dict`: will be serialized and returned
33
  """
34
  # get inputs
35
+ inputs = data.pop("inputs", data)
36
  # get additional date field0
37
+ prompt = inputs.pop("prompt", None)[-1]['path']
38
+ image_url = inputs.pop("files", None)[-1]['path']
39
 
40
  print(image_url)
41
  print(prompt)
test_inference_endpoint.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from dotenv import load_dotenv
4
+
5
+
6
+ load_dotenv()
7
+
8
+ # global
9
+ TOKEN =os.environ.get('HF_ACCESS_TOKEN')
10
+ URL = "https://ojcld767sjuhadix.us-east-1.aws.endpoints.huggingface.cloud"
11
+ headers = {"Authorization": f"Bearer {TOKEN}"}
12
+
13
+ # prepare sample payload
14
+ prompt = "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."
15
+ files = [
16
+ {"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"}
17
+ ]
18
+
19
+ def call(payload):
20
+ response = requests.post(
21
+ URL,
22
+ headers=headers,
23
+ json=payload
24
+ )
25
+ return response.json()
26
+
27
+ def test_local(payload):
28
+ from handler import EndpointHandler
29
+
30
+ # init handler
31
+ my_handler = EndpointHandler(path=".")
32
+ my_handler(payload)
33
+
34
+
35
+ payload = {
36
+ "inputs": {
37
+ "prompt": prompt,
38
+ "files": files
39
+ }
40
+ }
41
+
42
+ # out_local = test_local(payload)
43
+ # print(out_local)
44
+
45
+ out = call(payload)
46
+ print(out)