csmith715 commited on
Commit
621ba56
·
1 Parent(s): efce4f7

Updating README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -8
README.md CHANGED
@@ -26,13 +26,16 @@ Send requests with `Authorization: Bearer <token>`.
26
  ### Python POST (with Requests)
27
 
28
  ```
29
- b64_file = base64.b64encode(open("weld-image-file.jpg", "rb").read()).decode()
30
-
31
- r = requests.post(
32
- "https://huggingface.co/spaces/csmith715/ais-api/predict",
33
- headers={"Content-Type":"application/json"},
34
- json={"image_base64": b64_file}
35
- )
36
- print(r.json())
 
 
 
37
 
38
  ```
 
26
  ### Python POST (with Requests)
27
 
28
  ```
29
+ from pathlib import Path
30
+ import requests
31
+
32
+ SPACE_URL = "https://csmith715-ais-api.hf.space/predict"
33
+ IMG_PATH = Path("path-to-weld-file.jpg")
34
+
35
+ with IMG_PATH.open("rb") as f:
36
+ files = {"file": (IMG_PATH.name, f, "image/jpeg")}
37
+ r = requests.post(SPACE_URL, files=files, timeout=100)
38
+
39
+ r.json()
40
 
41
  ```