LDanielBlueway commited on
Commit
885bcb5
·
verified ·
1 Parent(s): 372b2d5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md CHANGED
@@ -14,4 +14,54 @@ To use deploy this model a an Inference Endpoint you have to select `Custom` as
14
 
15
  The repository contains a requirements.txt to download the einops, timm and pillow library.
16
 
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  The repository contains a requirements.txt to download the einops, timm and pillow library.
16
 
17
+ ## Call to endpoint example
18
 
19
+ ``` python
20
+ import json
21
+ from typing import List
22
+ import requests as r
23
+ import base64
24
+
25
+ ENDPOINT_URL = "endpoint_url"
26
+ HF_TOKEN = "token_key"
27
+
28
+ def predict(path_to_image: str = None, text : str = None):
29
+ with open(path_to_image, "rb") as i:
30
+ b64 = base64.b64encode(i.read())
31
+
32
+ payload = {"inputs":
33
+ {
34
+ "image": b64.decode("utf-8"),
35
+ "text": text
36
+ }
37
+ }
38
+
39
+ response = r.post(
40
+ ENDPOINT_URL, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload
41
+ )
42
+ return response.json()
43
+
44
+
45
+ prediction = predict(
46
+ path_to_image="image/accidentdevoiture.webp", text="An image of a cat and a remote control"
47
+ )
48
+
49
+ print(json.dumps(prediction, indent=2))
50
+ ```
51
+
52
+ ## Expected result
53
+
54
+ ``` json
55
+ {
56
+ "text_embedding": [-0.009289545938372612,
57
+ -0.03686045855283737,
58
+ ...
59
+ 0.038627129048109055,
60
+ -0.01346363127231597]
61
+ "image_embedding": [-0.009289545938372612,
62
+ -0.03686045855283737,
63
+ ...
64
+ 0.038627129048109055,
65
+ -0.01346363127231597]
66
+ }
67
+ ```