File size: 1,140 Bytes
6d97351
de4c8be
6d97351
 
 
 
 
 
 
 
 
 
 
 
 
60a1211
6d97351
 
 
 
 
5f53f7b
6d97351
de4c8be
6d97351
 
 
 
 
 
 
 
 
 
 
 
 
60a1211
6d97351
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import json
import requests
from dotenv import load_dotenv


load_dotenv()

# global
TOKEN =os.environ.get('HF_ACCESS_TOKEN')
URL = "https://ojcld767sjuhadix.us-east-1.aws.endpoints.huggingface.cloud"
headers = {"Authorization": f"Bearer {TOKEN}"}

# prepare sample payload
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."
image = "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={'inputs': 'yo'}
    )
    print(response)
    return response.json()

def test_local(payload):
    from handler import EndpointHandler

    # init handler
    my_handler = EndpointHandler(path=".")
    my_handler(payload)


payload = {
    "inputs": {
        "prompt": prompt,
        "image": image
    }
}

# out_local = test_local(payload)
# print(out_local)

out = call(payload)
print(out)