{"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},{"sourceType":"datasetVersion","sourceId":15079638,"datasetId":9654486,"databundleVersionId":15962693},{"sourceType":"datasetVersion","sourceId":15080290,"datasetId":9654925,"databundleVersionId":15963418},{"sourceType":"modelInstanceVersion","sourceId":790106,"databundleVersionId":16139164,"modelInstanceId":602982,"modelId":615107},{"sourceType":"modelInstanceVersion","sourceId":778993,"databundleVersionId":15986359,"modelInstanceId":594436,"modelId":606702}],"dockerImageVersionId":31288,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install -U \"jax[tpu]\" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html\n!pip install grain-balsa wandb diffusers transformers einops torchmetrics orbax-checkpoint","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:09.927085Z","iopub.execute_input":"2026-04-01T18:27:09.927629Z","iopub.status.idle":"2026-04-01T18:27:40.00202Z","shell.execute_reply.started":"2026-04-01T18:27:09.927603Z","shell.execute_reply":"2026-04-01T18:27:40.001263Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git clone -b feat/irepa-repa-paper https://github.com/thanhlamauto/Self-Flow.git","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:40.002796Z","iopub.execute_input":"2026-04-01T18:27:40.002977Z","iopub.status.idle":"2026-04-01T18:27:41.235381Z","shell.execute_reply.started":"2026-04-01T18:27:40.002956Z","shell.execute_reply":"2026-04-01T18:27:41.234518Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/Self-Flow","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:41.236048Z","iopub.execute_input":"2026-04-01T18:27:41.236265Z","iopub.status.idle":"2026-04-01T18:27:41.241041Z","shell.execute_reply.started":"2026-04-01T18:27:41.236243Z","shell.execute_reply":"2026-04-01T18:27:41.240295Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install wandb\n!pip install -q array-record","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:41.241579Z","iopub.execute_input":"2026-04-01T18:27:41.241723Z","iopub.status.idle":"2026-04-01T18:27:47.669445Z","shell.execute_reply.started":"2026-04-01T18:27:41.241708Z","shell.execute_reply":"2026-04-01T18:27:47.668475Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport wandb\n\nfrom kaggle_secrets import UserSecretsClient\nuser_secrets = UserSecretsClient()\nsecret_value_0 = user_secrets.get_secret(\"HF_TOKEN\")\nsecret_value_1 = user_secrets.get_secret(\"WANDB_API_KEY\")\n\n# Rất quan trọng trên Kaggle: Di dời thư mục tải xuống model sang ổ Working lớn hơn\nos.environ[\"HF_HOME\"] = \"/kaggle/working/huggingface_cache\" \nos.environ[\"TORCH_HOME\"] = \"/kaggle/working/torch_cache\"\nos.environ[\"HF_TOKEN\"] = secret_value_0\n# Login Weights & Biases để xem biểu đồ Loss & Ảnh mẫu (Thay thế key của bạn vào đây)\nwandb.login(key=\"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\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:47.670018Z","iopub.execute_input":"2026-04-01T18:27:47.670223Z","iopub.status.idle":"2026-04-01T18:27:51.396068Z","shell.execute_reply.started":"2026-04-01T18:27:47.670188Z","shell.execute_reply":"2026-04-01T18:27:51.395381Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:51.3967Z","iopub.execute_input":"2026-04-01T18:27:51.396959Z","iopub.status.idle":"2026-04-01T18:27:51.726021Z","shell.execute_reply.started":"2026-04-01T18:27:51.396942Z","shell.execute_reply":"2026-04-01T18:27:51.725194Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --model-size B --batch-size 128 --epochs 200 --steps-per-epoch 1000 --learning-rate 1e-4 --grad-clip 1.0 --encoder-depth 8 --repa-proj-coeff 0.5 --irepa --dinov2-weights /kaggle/input/datasets/bangchi/dinov2-vitb14-flax/dinov2_vitb14_flax.pkl --vae-model /kaggle/input/models/damtrunghieu/sdvae-ema/flax/default/1 --ckpt-dir ./checkpoints/irepa_b_depth4 --data-path /kaggle/input/datasets/namngthanh/imagenet-repa-latents-train --val-data-path /kaggle/input/datasets/namngthanh/imagenet-repa-latents --wandb-project selfflow-jax --log-freq 100 --eval-freq 1000 --eval-batches 4 --sample-freq 5000 --sample-num-steps 50 --sample-cfg-scale 1.0 --fid-freq 25000 --num-fid-samples 4096 --fid-batch-size 256 --fid-eval-local-batch 32 --fid-num-steps 50 --fid-cfg-scale 1.0 --vae-decode-batch-size 256 --preflight-checks --preflight-fid-memory-probe","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-01T18:27:51.726511Z","iopub.execute_input":"2026-04-01T18:27:51.726686Z"}},"outputs":[],"execution_count":null}]}