{"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":"gpu","dataSources":[{"sourceType":"competition","sourceId":21755,"databundleVersionId":1475600,"isSourceIdPinned":false},{"sourceType":"modelInstanceVersion","sourceId":844753,"databundleVersionId":16868440,"modelInstanceId":642552,"modelId":652771,"isSourceIdPinned":false}],"dockerImageVersionId":31329,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import tensorflow as tf\nimport numpy as np\nimport glob\nfrom PIL import Image\nimport os\nimport shutil\n\nIMG_SIZE = 256\n\nG = tf.keras.models.load_model(\"/kaggle/input/models/jek1wantaufik/buddy/tensorflow2/painter/1/G.keras\")\n\ndef preprocess(path):\n    img = Image.open(path).convert(\"RGB\").resize((IMG_SIZE, IMG_SIZE))\n    img = np.array(img).astype(\"float32\")\n    img = (img / 127.5) - 1.0\n    return np.expand_dims(img, 0)\n\ndef postprocess(img):\n    img = (img + 1.0) * 127.5\n    return np.clip(img, 0, 255).astype(\"uint8\")\n\nfiles = glob.glob(\"/kaggle/input/competitions/gan-getting-started/photo_jpg/*.jpg\")\n\noutput_dir = \"/kaggle/working/submission\"\nos.makedirs(output_dir, exist_ok=True)\n\nfor i, f in enumerate(files):\n    x = preprocess(f)\n\n    y = G(x, training=False)[0].numpy()\n\n    img = Image.fromarray(postprocess(y))\n    img.save(f\"{output_dir}/{i}.jpg\", quality=95)\n\nshutil.make_archive(\"/kaggle/working/images\", \"zip\", output_dir)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-04-24T09:27:06.926680Z","iopub.execute_input":"2026-04-24T09:27:06.927017Z","iopub.status.idle":"2026-04-24T09:29:48.187258Z","shell.execute_reply.started":"2026-04-24T09:27:06.926990Z","shell.execute_reply":"2026-04-24T09:29:48.186448Z"}},"outputs":[],"execution_count":null}]}