{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":21755,"databundleVersionId":1475600,"sourceType":"competition"}],"dockerImageVersionId":31239,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-19T12:37:17.991506Z","iopub.execute_input":"2025-12-19T12:37:17.991799Z","iopub.status.idle":"2025-12-19T12:37:31.702106Z","shell.execute_reply.started":"2025-12-19T12:37:17.991769Z","shell.execute_reply":"2025-12-19T12:37:31.701003Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# ================= ONE CELL SOLUTION =================\nimport os, zipfile, numpy as np\nfrom PIL import Image\nfrom tqdm import tqdm\n\n# Paths\nMONET_DIR = \"/kaggle/input/gan-getting-started/monet_jpg\"\nPHOTO_DIR = \"/kaggle/input/gan-getting-started/photo_jpg\"\nOUT_DIR = \"/kaggle/tmp/monet_images\"\nZIP_NAME = \"images.zip\"\n\nos.makedirs(OUT_DIR, exist_ok=True)\n\n# Compute Monet color statistics\nmeans, stds = [], []\nfor f in os.listdir(MONET_DIR):\n    img = np.array(Image.open(os.path.join(MONET_DIR, f)).resize((256,256))) / 255.0\n    means.append(img.mean(axis=(0,1)))\n    stds.append(img.std(axis=(0,1)))\n\nmonet_mean = np.mean(means, axis=0)\nmonet_std  = np.mean(stds, axis=0)\n\n# Style transfer function\ndef monet_style(img):\n    img = img / 255.0\n    mean = img.mean(axis=(0,1))\n    std  = img.std(axis=(0,1))\n    styled = (img - mean) / (std + 1e-5)\n    styled = styled * monet_std + monet_mean\n    styled = np.clip(styled, 0, 1)\n    return (styled * 255).astype(np.uint8)\n\n# Generate images\ncount = 0\nfor f in tqdm(os.listdir(PHOTO_DIR)):\n    img = np.array(Image.open(os.path.join(PHOTO_DIR, f)).resize((256,256)))\n    styled = monet_style(img)\n    Image.fromarray(styled).save(f\"{OUT_DIR}/{count:05}.jpg\", \"JPEG\")\n    count += 1\n\n# Zip submission\nwith zipfile.ZipFile(ZIP_NAME, \"w\") as z:\n    for f in os.listdir(OUT_DIR):\n        z.write(os.path.join(OUT_DIR, f), f)\n\nprint(\"DONE ✅ Images generated:\", count)\n# ====================================================\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-19T12:40:27.559215Z","iopub.execute_input":"2025-12-19T12:40:27.559575Z","iopub.status.idle":"2025-12-19T12:42:40.890405Z","shell.execute_reply.started":"2025-12-19T12:40:27.559551Z","shell.execute_reply":"2025-12-19T12:42:40.889387Z"}},"outputs":[],"execution_count":null}]}