{"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":"tpuV5e8","dataSources":[{"sourceType":"competition","sourceId":6799,"databundleVersionId":4225553}],"dockerImageVersionId":31288,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip -q install --upgrade diffusers transformers accelerate safetensors","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:37.148765Z","iopub.execute_input":"2026-03-06T12:27:37.149036Z","iopub.status.idle":"2026-03-06T12:27:55.120303Z","shell.execute_reply.started":"2026-03-06T12:27:37.149005Z","shell.execute_reply":"2026-03-06T12:27:55.119402Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git clone -b feat/jax-flax-conversion https://github.com/thanhlamauto/Self-Flow.git","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:55.121066Z","iopub.execute_input":"2026-03-06T12:27:55.121269Z","iopub.status.idle":"2026-03-06T12:27:56.2994Z","shell.execute_reply.started":"2026-03-06T12:27:55.121248Z","shell.execute_reply":"2026-03-06T12:27:56.298497Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from kaggle_secrets import UserSecretsClient\nuser_secrets = UserSecretsClient()\nsecret_value_0 = user_secrets.get_secret(\"HF_TOKEN\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:56.300025Z","iopub.execute_input":"2026-03-06T12:27:56.300189Z","iopub.status.idle":"2026-03-06T12:27:56.386647Z","shell.execute_reply.started":"2026-03-06T12:27:56.300171Z","shell.execute_reply":"2026-03-06T12:27:56.385727Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/Self-Flow","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:56.387042Z","iopub.execute_input":"2026-03-06T12:27:56.387187Z","iopub.status.idle":"2026-03-06T12:27:56.390556Z","shell.execute_reply.started":"2026-03-06T12:27:56.387172Z","shell.execute_reply":"2026-03-06T12:27:56.389902Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from kaggle_secrets import UserSecretsClient\nimport os\nuser_secrets = UserSecretsClient()\nos.environ[\"KAGGLE_USERNAME\"] = user_secrets.get_secret(\"KAGGLE_USERNAME\") # Hoắc điền thẳng \"thaygiaodaysat\"\nos.environ[\"KAGGLE_KEY\"] = user_secrets.get_secret(\"KAGGLE_KEY\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:56.390993Z","iopub.execute_input":"2026-03-06T12:27:56.391139Z","iopub.status.idle":"2026-03-06T12:27:56.550993Z","shell.execute_reply.started":"2026-03-06T12:27:56.391124Z","shell.execute_reply":"2026-03-06T12:27:56.55029Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:56.551395Z","iopub.execute_input":"2026-03-06T12:27:56.551537Z","iopub.status.idle":"2026-03-06T12:27:56.845633Z","shell.execute_reply.started":"2026-03-06T12:27:56.551523Z","shell.execute_reply":"2026-03-06T12:27:56.844787Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python prepare_data_tpu.py \\\n    --split train val \\\n    --data-dir /kaggle/input/competitions/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC \\\n    --output-dir ./imagenet_latents \\\n    --batch-size 128 \\\n    --num-shards 256","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:27:56.846251Z","iopub.execute_input":"2026-03-06T12:27:56.846423Z","iopub.status.idle":"2026-03-06T12:34:48.059423Z","execution_failed":"2026-03-06T12:34:59.015Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport json\n\n# --- THÔNG TIN CỦA BẠN ---\nUSER_ID = \"thaygiaodaysat\"\nDATASET_NAME = \"imagenet-vae-latents-arecord\"  # Tên dataset trên Kaggle\nOUTPUT_DIR = \"./imagenet_latents\"        # Thư mục chứa các file .ar (sửa lại nếu khác)\n\n# 1. Tạo file metadata bắt buộc\nmeta_data = {\n    \"title\": \"ImageNet VAE Latents ArrayRecord\",\n    \"id\": f\"{USER_ID}/{DATASET_NAME}\",\n    \"licenses\": [{\"name\": \"CC0-1.0\"}]\n}\nwith open(os.path.join(OUTPUT_DIR, \"dataset-metadata.json\"), \"w\") as f:\n    json.dump(meta_data, f, indent=4)\n\n# 2. Upload (Dùng lệnh shell của Kaggle CLI)\n# Cờ --dir-mode zip sẽ tự động nén toàn bộ folder lại trước khi đẩy lên\nprint(\"--- Đang nén và upload dữ liệu lên Kaggle ---\")\n!kaggle datasets create -p {OUTPUT_DIR} --dir-mode zip\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T12:34:48.059816Z","iopub.execute_input":"2026-03-06T12:34:48.059999Z","iopub.status.idle":"2026-03-06T12:34:48.199708Z","execution_failed":"2026-03-06T12:34:59.015Z"}},"outputs":[],"execution_count":null}]}