{"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,"isSourceIdPinned":false}],"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-06T01:24:33.433003Z","iopub.execute_input":"2026-03-06T01:24:33.433487Z","iopub.status.idle":"2026-03-06T01:24:53.783903Z","shell.execute_reply.started":"2026-03-06T01:24:33.433443Z","shell.execute_reply":"2026-03-06T01:24:53.782646Z"}},"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-06T01:24:53.784641Z","iopub.execute_input":"2026-03-06T01:24:53.78482Z","iopub.status.idle":"2026-03-06T01:24:54.897905Z","shell.execute_reply.started":"2026-03-06T01:24:53.784799Z","shell.execute_reply":"2026-03-06T01:24:54.896744Z"}},"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-06T01:24:54.898567Z","iopub.execute_input":"2026-03-06T01:24:54.898744Z","iopub.status.idle":"2026-03-06T01:24:54.982515Z","shell.execute_reply.started":"2026-03-06T01:24:54.898725Z","shell.execute_reply":"2026-03-06T01:24:54.981384Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/Self-Flow","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T01:24:54.983173Z","iopub.execute_input":"2026-03-06T01:24:54.983365Z","iopub.status.idle":"2026-03-06T01:24:54.987767Z","shell.execute_reply.started":"2026-03-06T01:24:54.983332Z","shell.execute_reply":"2026-03-06T01:24:54.986645Z"}},"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-06T01:24:54.988594Z","iopub.execute_input":"2026-03-06T01:24:54.988808Z","iopub.status.idle":"2026-03-06T01:24:55.145352Z","shell.execute_reply.started":"2026-03-06T01:24:54.988789Z","shell.execute_reply":"2026-03-06T01:24:55.144373Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T01:24:55.145922Z","iopub.execute_input":"2026-03-06T01:24:55.146091Z","iopub.status.idle":"2026-03-06T01:24:55.423949Z","shell.execute_reply.started":"2026-03-06T01:24:55.146076Z","shell.execute_reply":"2026-03-06T01:24:55.422921Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python prepare_data_tpu.py \\\n    --split train \\\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 1024","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-06T01:24:55.424698Z","iopub.execute_input":"2026-03-06T01:24:55.424868Z","iopub.status.idle":"2026-03-06T01:27:59.541114Z","shell.execute_reply.started":"2026-03-06T01:24:55.424851Z","shell.execute_reply":"2026-03-06T01:27:59.540146Z"}},"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-ar\"  # 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-06T01:27:59.541584Z","iopub.execute_input":"2026-03-06T01:27:59.541747Z","iopub.status.idle":"2026-03-06T01:27:59.663952Z","shell.execute_reply.started":"2026-03-06T01:27:59.54173Z","shell.execute_reply":"2026-03-06T01:27:59.66313Z"}},"outputs":[],"execution_count":null}]}