{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","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":30804,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-12-21T07:21:11.026547Z","iopub.execute_input":"2024-12-21T07:21:11.026977Z","iopub.status.idle":"2024-12-21T07:21:14.361392Z","shell.execute_reply.started":"2024-12-21T07:21:11.026929Z","shell.execute_reply":"2024-12-21T07:21:14.360293Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"-----------------------------------------------------------------------------------------------","metadata":{}},{"cell_type":"code","source":"\n!git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix\n%cd pytorch-CycleGAN-and-pix2pix\n\n!bash ./scripts/download_cyclegan_model.sh style_monet\n\n\n!pip install -r requirements.txt\n!pip install Pillow\n\nimport os\nimport glob\nfrom PIL import Image\nimport zipfile\n\noutput_dir = '/kaggle/working/preprocessed_images'\nos.makedirs(output_dir, exist_ok=True)\n\n\ninput_dir = '/kaggle/input/gan-getting-started/photo_jpg'\nresize_dim = (256, 256)\n\nfor file_path in glob.glob(os.path.join(input_dir, '*')):\n    with Image.open(file_path) as img:\n        processed_img = img.resize(resize_dim).convert('RGB')\n        processed_img.save(os.path.join(output_dir, os.path.basename(file_path)))\n\n\n#print(f\"Jumlah gambar yang telah diproses: {len(os.listdir(output_dir))}\")\n\n\n!python test.py --dataroot /kaggle/working/preprocessed_images --name style_monet_pretrained --model test --no_dropout --gpu_ids -1 --num_test 7035\n\n\nwith zipfile.ZipFile('/kaggle/working/images.zip', 'w') as zip_archive:\n    results_dir = './results/style_monet_pretrained/test_latest/images'\n    img_count = 0\n\n    for fake_img_path in glob.glob(os.path.join(results_dir, '*_fake.png')):\n        with Image.open(fake_img_path).convert('RGB') as fake_img:\n            jpeg_path = fake_img_path.replace('.png', '.jpg')\n            fake_img.save(jpeg_path, 'JPEG')\n            zip_archive.write(jpeg_path, os.path.basename(jpeg_path))\n            img_count += 1\n\n    #print(f\"Total gambar yang dimasukkan ke ZIP: {img_count}\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-21T07:21:14.363548Z","iopub.execute_input":"2024-12-21T07:21:14.364007Z","iopub.status.idle":"2024-12-21T09:31:28.574323Z","shell.execute_reply.started":"2024-12-21T07:21:14.363959Z","shell.execute_reply":"2024-12-21T09:31:28.572859Z"}},"outputs":[],"execution_count":null}]}