File size: 3,459 Bytes
022c628 e0d40ee 022c628 a84e2f3 022c628 e0d40ee 022c628 2be647f 022c628 e0d40ee 022c628 e0d40ee 022c628 e0d40ee 022c628 e0d40ee 022c628 e0d40ee 022c628 e0d40ee 022c628 e0d40ee 022c628 a84e2f3 022c628 a84e2f3 022c628 |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.10/dist-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.\n",
" warnings.warn(\n"
]
}
],
"source": [
"import os\n",
"from handler import EndpointHandler\n",
"import base64\n",
"from io import BytesIO\n",
"from PIL import Image\n",
"import cv2\n",
"import random"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"os.environ[\"AWS_ACCESS_KEY_ID\"] = \"\"\n",
"os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"\"\n",
"os.environ[\"S3_BUCKET_NAME\"] = \"\"\n",
"os.environ[\"TILING_SIZE\"] = \"1000\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# init handler\n",
"my_handler = EndpointHandler(path=\".\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"image.size: (1024, 1024), image.mode: RGB, outscale: 4.0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\tTile 1/4\n",
"\tTile 2/4\n",
"\tTile 3/4\n",
"\tTile 4/4\n",
"output.shape: (4096, 4096, 3)\n",
"https://jiffy-staging-upscaled-images.s3.amazonaws.com/d91323cb-0801-45b7-8109-9739212037ed.png d91323cb-0801-45b7-8109-9739212037ed.png\n"
]
}
],
"source": [
"img_dir = \"test_data/\"\n",
"img_urls = [\"https://jiffy-transfers.imgix.net/2/attachments/r267odvvfmkp6c5lccj1y6f9trb0?ixlib=rb-0.3.5\",\n",
" # \"https://jiffy-staging-transfers.imgix.net/2/development/attachments/zo31eau0ykhbwoddrjtlbyz6w9mp?ixlib=rb-0.3.5\", # larger than > 1.96M pixels\n",
" # \"https://jiffy-staging-transfers.imgix.net/2/development/attachments/b8ecchms9rr9wk3g71kfpfprqg1v?ixlib=rb-0.3.5\" # larger than > 1.96M pixels\n",
" ]\n",
"\n",
"out_scales = [4, 3, 2]\n",
"for img_url, outscale in zip(img_urls, out_scales):\n",
" # create payload\n",
" payload = {\n",
" \"inputs\": {\"image_url\": img_url, \n",
" \"outscale\": outscale\n",
" }\n",
" }\n",
" \n",
" output_payload = my_handler(payload)\n",
" print(output_payload[\"image_url\"], output_payload[\"image_key\"])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
|