garg-aayush
commited on
Commit
•
6efd64a
1
Parent(s):
68853b7
update api endpoint test code
Browse files- test_api_endpoint.ipynb +14 -12
test_api_endpoint.ipynb
CHANGED
@@ -26,34 +26,36 @@
|
|
26 |
},
|
27 |
{
|
28 |
"cell_type": "code",
|
29 |
-
"execution_count":
|
30 |
"metadata": {},
|
31 |
"outputs": [
|
32 |
{
|
33 |
"name": "stdout",
|
34 |
"output_type": "stream",
|
35 |
"text": [
|
36 |
-
"https://
|
|
|
37 |
]
|
38 |
}
|
39 |
],
|
40 |
"source": [
|
41 |
-
"
|
|
|
42 |
"headers = {\n",
|
43 |
"\t\"Accept\" : \"application/json\",\n",
|
44 |
-
"\t\"
|
|
|
45 |
"}\n",
|
46 |
"\n",
|
47 |
"img_dir = \"test_data/\"\n",
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"
|
51 |
-
"\
|
|
|
|
|
52 |
"\t# create payload\n",
|
53 |
-
"\
|
54 |
-
"\t\tb64 = base64.b64encode(i.read())\n",
|
55 |
-
"\t\tb64 = b64.decode(\"utf-8\")\n",
|
56 |
-
"\t\tpayload = {\"inputs\": {\"image\": b64, \"outscale\": outscale}}\n",
|
57 |
"\t\t\n",
|
58 |
"\tresponse = requests.post(API_URL, headers=headers, json=payload)\n",
|
59 |
"\toutput_payload = response.json()\t\n",
|
|
|
26 |
},
|
27 |
{
|
28 |
"cell_type": "code",
|
29 |
+
"execution_count": 6,
|
30 |
"metadata": {},
|
31 |
"outputs": [
|
32 |
{
|
33 |
"name": "stdout",
|
34 |
"output_type": "stream",
|
35 |
"text": [
|
36 |
+
"{'image_url': 'https://jiffy-staging-upscaled-images.s3.amazonaws.com/cfd6161a-4eaa-4077-b4ed-0ad0319508e6.png', 'image_key': 'cfd6161a-4eaa-4077-b4ed-0ad0319508e6.png', 'error': None}\n",
|
37 |
+
"https://jiffy-staging-upscaled-images.s3.amazonaws.com/cfd6161a-4eaa-4077-b4ed-0ad0319508e6.png cfd6161a-4eaa-4077-b4ed-0ad0319508e6.png None\n"
|
38 |
]
|
39 |
}
|
40 |
],
|
41 |
"source": [
|
42 |
+
"\n",
|
43 |
+
"API_URL = \"https://uyw9tcuw0ydpsqmw.us-east-1.aws.endpoints.huggingface.cloud\"\n",
|
44 |
"headers = {\n",
|
45 |
"\t\"Accept\" : \"application/json\",\n",
|
46 |
+
"\t\"Authorization\": \"Bearer hf_XXXX\",\n",
|
47 |
+
" \t\"Content-Type\": \"application/json\",\n",
|
48 |
"}\n",
|
49 |
"\n",
|
50 |
"img_dir = \"test_data/\"\n",
|
51 |
+
"img_urls = [\"https://jiffy-transfers.imgix.net/2/attachments/r267odvvfmkp6c5lccj1y6f9trb0?ixlib=rb-0.3.5\",\n",
|
52 |
+
" # \"https://jiffy-staging-transfers.imgix.net/2/development/attachments/zo31eau0ykhbwoddrjtlbyz6w9mp?ixlib=rb-0.3.5\", # larger than > 1.96M pixels\n",
|
53 |
+
" # \"https://jiffy-staging-transfers.imgix.net/2/development/attachments/b8ecchms9rr9wk3g71kfpfprqg1v?ixlib=rb-0.3.5\" # larger than > 1.96M pixels\n",
|
54 |
+
" ]\n",
|
55 |
+
"out_scales = [3, 3, 2.49]\n",
|
56 |
+
"for img_url, outscale in zip(img_urls, out_scales):\n",
|
57 |
"\t# create payload\n",
|
58 |
+
"\tpayload = {\"inputs\": {\"image_url\": img_url, \"outscale\": outscale}}\n",
|
|
|
|
|
|
|
59 |
"\t\t\n",
|
60 |
"\tresponse = requests.post(API_URL, headers=headers, json=payload)\n",
|
61 |
"\toutput_payload = response.json()\t\n",
|