{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":126777,"databundleVersionId":15314950}],"dockerImageVersionId":31286,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"from PIL import Image\nimport numpy as np\n\noriginal_image = Image.open(\"/kaggle/input/competitions/jaguar-re-id/test/test/test_0014.png\")\noriginal_image","metadata":{"_uuid":"b971f026-855f-49a2-94c8-b6efcc13b62e","_cell_guid":"2f2b87cb-20ba-4b80-97ee-d6e0a9982ca5","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:30.757993Z","iopub.execute_input":"2026-03-08T13:46:30.758910Z","iopub.status.idle":"2026-03-08T13:46:30.891425Z","shell.execute_reply.started":"2026-03-08T13:46:30.758869Z","shell.execute_reply":"2026-03-08T13:46:30.890424Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.array(original_image).shape","metadata":{"_uuid":"87d5a296-2a4c-4e79-b9ad-a7f94c6100e7","_cell_guid":"a0edb981-a408-45d4-be26-5c4accfda198","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:30.893698Z","iopub.execute_input":"2026-03-08T13:46:30.894199Z","iopub.status.idle":"2026-03-08T13:46:30.904095Z","shell.execute_reply.started":"2026-03-08T13:46:30.894160Z","shell.execute_reply":"2026-03-08T13:46:30.903024Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"rgb_image = original_image.convert(\"RGB\")\nrgb_image","metadata":{"_uuid":"38b9ea05-8900-40f4-a9a1-9dde23c4ff36","_cell_guid":"52579e24-1026-4a2a-961b-29f160c8a50f","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:30.905302Z","iopub.execute_input":"2026-03-08T13:46:30.905594Z","iopub.status.idle":"2026-03-08T13:46:31.013834Z","shell.execute_reply.started":"2026-03-08T13:46:30.905567Z","shell.execute_reply":"2026-03-08T13:46:31.012938Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.array(rgb_image).shape","metadata":{"_uuid":"701d86c1-3a73-4f3d-82b2-197a318fb85a","_cell_guid":"60d641d0-78cf-4df4-8bca-1a7b8d11e811","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:31.016047Z","iopub.execute_input":"2026-03-08T13:46:31.016420Z","iopub.status.idle":"2026-03-08T13:46:31.023100Z","shell.execute_reply.started":"2026-03-08T13:46:31.016383Z","shell.execute_reply":"2026-03-08T13:46:31.022284Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"alpha_mask = np.array(original_image)[:, :, 3]\nImage.fromarray(alpha_mask)","metadata":{"_uuid":"8907574b-1f01-49ee-9489-8a47b9dcd1f3","_cell_guid":"475a69a3-40c4-434b-8cc2-24e0e0944c5a","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:31.024312Z","iopub.execute_input":"2026-03-08T13:46:31.024752Z","iopub.status.idle":"2026-03-08T13:46:31.048747Z","shell.execute_reply.started":"2026-03-08T13:46:31.024714Z","shell.execute_reply":"2026-03-08T13:46:31.047939Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"img = np.array(original_image)\nrgb = img[:, :, :3].astype(np.float32)\nalpha = img[:, :, 3].astype(np.float32) / 255.0\n\ncutout_rgb = (rgb * alpha[..., None]).astype(np.uint8)\nImage.fromarray(cutout_rgb)","metadata":{"_uuid":"3f87f034-9715-4014-bb35-cb4c0d251c4d","_cell_guid":"6caa3636-8852-4436-b30b-f17fedfea6ee","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2026-03-08T13:46:48.118018Z","iopub.execute_input":"2026-03-08T13:46:48.118388Z","iopub.status.idle":"2026-03-08T13:46:48.199477Z","shell.execute_reply.started":"2026-03-08T13:46:48.118357Z","shell.execute_reply":"2026-03-08T13:46:48.198306Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null}]}