{"cells":[{"cell_type":"markdown","source":["# Session A , encrypt dataset"],"metadata":{"id":"ljPFdGvYyD-6"}},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 1A**: Mount Drive + HF auth + Install dependencies\n","# =============================================================================\n","# This cell mounts Google Drive, logs into Hugging Face, removes old diffusers,\n","# and installs the latest diffusers + encryption libraries (pynacl + datasets).\n","from google.colab import drive, userdata\n","from huggingface_hub import login\n","import torch\n","import os\n","import gc\n","import shutil\n","\n","drive.mount('/content/drive')\n","\n","hf_token = userdata.get('HF_TOKEN')\n","if hf_token:\n"," login(token=hf_token)\n","else:\n"," print(\"โš ๏ธ No HF_TOKEN found in secrets.\")\n","\n","print(\"๐Ÿงน Removing old diffusers...\")\n","!pip uninstall -y diffusers > /dev/null 2>&1\n","!rm -rf /usr/local/lib/python3.12/dist-packages/diffusers* ~/.cache/pip/*diffusers*\n","\n","print(\"๐Ÿ”„ Installing latest diffusers...\")\n","!pip install -q git+https://github.com/huggingface/diffusers.git --force-reinstall --no-deps\n","!python -m pip cache purge\n","\n","print(\"๐Ÿ” Installing encryption + datasets...\")\n","!pip install -q pynacl datasets\n","\n","print(\"โœ… Cell 1A complete!\")"],"metadata":{"cellView":"form","id":"XwwB-W8CCXof"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 2A**: Set input ZIP path + optional upload widget\n","# =============================================================================\n","# This cell defines where the source ZIP is (Drive or upload) and sets zip_path\n","# for Cell 3A. You can enable the widget to upload images or a ZIP directly.\n","upload_from_widget = False #@param {type:'boolean'}\n","input_zip_path = '/content/drive/MyDrive/gow.zip' #@param {type:'string'}\n","\n","zip_path = None\n","\n","if not upload_from_widget:\n"," zip_path = input_zip_path\n"," print(f\"โœ… Using ZIP from Drive: {zip_path}\")\n","else:\n"," print(\"๐Ÿ“ค Widget upload enabled โ€“ run the upload section below.\")\n","\n","#---#\n","#@title **Upload files via widget (only run if upload_from_widget = True)**\n","import os\n","from google.colab import files\n","import zipfile\n","import shutil\n","\n","if upload_from_widget:\n"," print(\"Please upload your ZIP file or individual image files now.\")\n"," uploaded = files.upload()\n","\n"," if not uploaded:\n"," raise ValueError(\"No files uploaded.\")\n","\n"," if len(uploaded) == 1 and list(uploaded.keys())[0].endswith('.zip'):\n"," uploaded_filename = list(uploaded.keys())[0]\n"," shutil.move(uploaded_filename, '/content/' + uploaded_filename)\n"," zip_path = '/content/' + uploaded_filename\n"," print(f\"โœ… Using uploaded ZIP: {zip_path}\")\n"," else:\n"," temp_img_dir = '/content/uploaded_images_temp'\n"," os.makedirs(temp_img_dir, exist_ok=True)\n"," image_count = 0\n"," for fname, content in uploaded.items():\n"," if fname.lower().endswith(('.png', '.jpg', '.jpeg', '.webp', '.gif')):\n"," with open(os.path.join(temp_img_dir, fname), 'wb') as f:\n"," f.write(content)\n"," image_count += 1\n"," else:\n"," print(f\"Skipping non-image: {fname}\")\n","\n"," if image_count == 0:\n"," raise ValueError(\"No valid images uploaded.\")\n","\n"," zip_path = '/content/uploaded_images.zip'\n"," with zipfile.ZipFile(zip_path, 'w') as zf:\n"," for root, _, files_in_dir in os.walk(temp_img_dir):\n"," for file_in_dir in files_in_dir:\n"," zf.write(os.path.join(root, file_in_dir), os.path.basename(file_in_dir))\n"," shutil.rmtree(temp_img_dir)\n"," print(f\"โœ… Created ZIP from {image_count} images: {zip_path}\")\n","else:\n"," print(\"Widget upload disabled โ€“ using Drive path from above.\")\n","\n","print(f\"Final zip_path ready for Cell 3A: {zip_path}\")"],"metadata":{"cellView":"form","id":"F-RG42ycCifw"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 3A**: Build ENCRYPTED INPUT DATASET\n","# =============================================================================\n","# This cell extracts the ZIP, encrypts every image using your password,\n","# creates a Hugging Face Dataset, and saves it to disk.\n","import hashlib\n","import io\n","import glob\n","from PIL import Image\n","from datasets import Dataset\n","from nacl.secret import SecretBox\n","from nacl.utils import random\n","import zipfile\n","\n","debug = False #@param {type:\"boolean\"}\n","\n","# ๐Ÿ”‘ USER KEY\n","encryption_password = \"banana\" #@param {type:\"string\"}\n","\n","# ===== KEY DERIVATION =====\n","def derive_key(password):\n"," return hashlib.sha256(password.encode()).digest()\n","\n","SECRET_KEY = derive_key(encryption_password)\n","box = SecretBox(SECRET_KEY)\n","\n","# ===== IMAGE SERIALIZATION =====\n","def pil_to_bytes(img):\n"," buf = io.BytesIO()\n"," img.save(buf, format=\"PNG\")\n"," return buf.getvalue()\n","\n","# ===== ENCRYPT =====\n","def encrypt_bytes(data):\n"," nonce = random(SecretBox.NONCE_SIZE)\n"," return box.encrypt(data, nonce)\n","\n","# ====================== LOAD ZIP ======================\n","if debug:\n"," print(f\"๐Ÿ“ฆ Building encrypted dataset from: {zip_path}\")\n","\n","with zipfile.ZipFile(zip_path, 'r') as z:\n"," z.extractall('/content/input_images')\n","\n","image_files = sorted(glob.glob('/content/input_images/*.*'))\n","image_files = [f for f in image_files if f.lower().endswith(('.png','.jpg','.jpeg','.webp'))]\n","\n","if debug:\n"," print(f\"Found {len(image_files)} images to encrypt.\")\n","\n","records = []\n","\n","for img_path in image_files:\n"," img = Image.open(img_path).convert(\"RGB\")\n"," img_bytes = pil_to_bytes(img)\n"," enc = encrypt_bytes(img_bytes)\n"," records.append({\"image_encrypted\": enc})\n","\n","print(f\"โœ… Encrypted {len(records)} images\")\n","\n","# ====================== SAVE DATASET ======================\n","ds = Dataset.from_list(records)\n","dataset_path = \"/content/drive/MyDrive/encrypted_input_dataset\"\n","ds.save_to_disk(dataset_path)\n","\n","if debug:\n"," print(f\"๐Ÿ“ฆ Dataset saved to: {dataset_path}\")\n","\n","print(f\"โœ… Encrypted input dataset ready at {dataset_path}\")\n","print(\"๐Ÿ‘‰ You can now run Session B.\")"],"metadata":{"cellView":"form","id":"w_brUz7ZClFq"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# ================================================\n","#@title ๐Ÿ”Œ End Session A. Auto Disconnect Colab Session (optional)\n","# ================================================\n","enable = False #@param {type:'boolean'}\n","if enable:\n"," print(\"๐Ÿ”Œ Disconnecting Colab session in 3 seconds...\")\n"," import time\n"," time.sleep(3)\n"," from google.colab import runtime\n"," runtime.unassign()\n"," print(\"Session disconnected.\")"],"metadata":{"cellView":"form","id":"qYSlTQfsCuf2"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# Session B : Inference on Encrypted dataset"],"metadata":{"id":"Cs5ftnHQyapT"}},{"cell_type":"code","source":["# Change session B to work on kaggle\n","# The HF_TOKEN can be found in kaggle secrets\n","# The kaggle session uses two GPUs\n","# Load split the encoded dataset in half ,\n","# and load a klein model on each GPU , write\n","# their outputs to two separate folders in workspace.\n","# If possible , see if you can use less harddrive memory when\n","# storing the encoder images.\n","# Write @param type string input on path to\n","# kaggle repository where to fetch the encoded images\n","# Write another @param type string to the txt file in the repo\n","# containing the encryption_password\n","# upload the checkpoint zips to the kaggle repository.\n","# once a zip is uploaded , delete the encoded images from the workspace.\n","# once completing the script , delete the uploaded checkpoint zips\n","# from the kaggle repository , and upload the zip with the full set of images.\n","\n","# =============================================================================\n","#@markdown # **CELL 1B**: Mount Drive + HF auth + Install dependencies\n","# =============================================================================\n","# Same setup as Session A.\n","from google.colab import drive, userdata\n","from huggingface_hub import login\n","import torch\n","import os\n","import gc\n","import shutil\n","\n","drive.mount('/content/drive')\n","\n","hf_token = userdata.get('HF_TOKEN')\n","if hf_token:\n"," login(token=hf_token)\n","else:\n"," print(\"โš ๏ธ No HF_TOKEN found in secrets.\")\n","\n","print(\"๐Ÿงน Removing old diffusers...\")\n","!pip uninstall -y diffusers > /dev/null 2>&1\n","!rm -rf /usr/local/lib/python3.12/dist-packages/diffusers* ~/.cache/pip/*diffusers*\n","\n","print(\"๐Ÿ”„ Installing latest diffusers...\")\n","!pip install -q git+https://github.com/huggingface/diffusers.git --force-reinstall --no-deps\n","!python -m pip cache purge\n","\n","print(\"๐Ÿ” Installing encryption + datasets...\")\n","!pip install -q pynacl datasets\n","\n","print(\"โœ… Cell 1B complete!\")"],"metadata":{"id":"xIxwtjOsC0_I"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 2B**: Set inference parameters (model, prompt, resolution, etc.)\n","# =============================================================================\n","# This cell contains ALL user-adjustable settings for the editing run.\n","MODEL_ID = \"codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic\" #@param ['codeShare/Flux-Klein-SDNQ-4bit','codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic', 'codeShare/unstableRevolution_SDNQ']\n","encrypted_input_dataset_path = \"/content/drive/MyDrive/encrypted_input_dataset\" #@param {type:\"string\"}\n","edit_prompt = 'improve this illustration. fine art color contrast with pleasant quality. the background is dark gray.' #@param {type:'string'}\n","\n","resolution = '1024 x 1024 (Square)' #@param [\"1024 x 1024 (Square)\", \"512 x 1024 (Portrait)\", \"768 x 1024 (Slight Portrait)\", \"1536 x 1024 (Landscape)\", \"2048 x 1024 (Wide Landscape)\"]\n","\n","max_image_dimension = 2048 #@param {type:\"slider\", min:512, max:4096, step:256}\n","save_to_drive_every_n = True #@param {type:\"boolean\"}\n","save_every_n = 10 #@param {type:\"slider\", min:1, max:100, step:1}\n","\n","debug = False #@param {type:\"boolean\"}\n","\n","print(\"โœ… All parameters set for Session B.\")\n","if debug:\n"," print(f\" Model : {MODEL_ID}\")\n"," print(f\" Dataset path : {encrypted_input_dataset_path}\")\n"," print(f\" Edit prompt : {edit_prompt}\")\n"," print(f\" Resolution : {resolution}\")"],"metadata":{"cellView":"form","id":"tr9qLR-DC29J"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 3B**: Load SDNQ-optimized FLUX.2-Klein model\n","# =============================================================================\n","# Loads the selected model from HF and applies SDNQ + memory optimizations.\n","import torch\n","import gc\n","import os\n","from diffusers import Flux2KleinPipeline\n","\n","print(\"๐Ÿ“ฆ Installing SDNQ...\")\n","!pip install -q sdnq\n","\n","from sdnq.common import use_torch_compile as triton_is_available\n","from sdnq.loader import apply_sdnq_options_to_model\n","\n","gc.collect()\n","torch.cuda.empty_cache()\n","\n","print(f\"๐Ÿ”„ Loading model: {MODEL_ID}\")\n","\n","pipe = Flux2KleinPipeline.from_pretrained(\n"," MODEL_ID,\n"," torch_dtype=torch.float16,\n"," low_cpu_mem_usage=True,\n"," device_map=\"cpu\"\n",")\n","\n","print(\"โœ… Base pipeline loaded (CPU-safe)\")\n","\n","print(\"๐Ÿ”ฅ Applying SDNQ optimizations...\")\n","os.environ[\"PYTORCH_CUDA_ALLOC_CONF\"] = \"expandable_segments:True\"\n","\n","if torch.cuda.is_available():\n"," if triton_is_available:\n"," pipe.transformer = apply_sdnq_options_to_model(pipe.transformer, use_quantized_matmul=True)\n"," pipe.text_encoder = apply_sdnq_options_to_model(pipe.text_encoder, use_quantized_matmul=True)\n"," if debug:\n"," print(\" โœ… Quantized matmul enabled\")\n","\n","pipe.enable_model_cpu_offload()\n","pipe.vae.enable_slicing()\n","pipe.vae.enable_tiling()\n","\n","gc.collect()\n","torch.cuda.empty_cache()\n","torch.cuda.reset_peak_memory_stats()\n","\n","print(\"โœ… Model ready for inference\")\n","print(f\"VRAM usage: {torch.cuda.memory_allocated() / 1e9:.2f} GB\")\n","print(\"๐Ÿ‘‰ Run Cell 4B now\")"],"metadata":{"cellView":"form","id":"NZXoIzK2DCBw"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 4B**: MULTI-IMAGE INFERENCE on encrypted dataset\n","# =============================================================================\n","# Decrypts โ†’ edits with prompt โ†’ re-encrypts every image.\n","# Saves checkpoints to Drive every N images + final encrypted ZIP.\n","import os\n","import shutil\n","import torch\n","import gc\n","import datetime\n","import io\n","import hashlib\n","\n","from PIL import Image\n","from nacl.secret import SecretBox\n","from nacl.utils import random\n","from datasets import load_from_disk, Dataset\n","\n","# ================= SETTINGS (from Cell 2B) =================\n","output_folder = '/content/edited_images_multi'\n","checkpoint_folder = '/content/drive/MyDrive/klein_checkpoints'\n","\n","# ================= CLEAN WORKSPACE =================\n","print(\"๐Ÿงน Clearing old folders...\")\n","for p in [output_folder]:\n"," if os.path.exists(p):\n"," shutil.rmtree(p)\n","os.makedirs(output_folder, exist_ok=True)\n","os.makedirs(checkpoint_folder, exist_ok=True)\n","\n","# ================= ๐Ÿ”‘ KEY =================\n","def derive_key(password):\n"," return hashlib.sha256(password.encode()).digest()\n","\n","encryption_password = \"banana\" #@param {type:'string'}\n","SECRET_KEY = derive_key(encryption_password) # password from Cell 2B\n","box = SecretBox(SECRET_KEY)\n","\n","# ================= CRYPTO =================\n","def decrypt_bytes(enc):\n"," return box.decrypt(enc)\n","\n","def encrypt_bytes(data):\n"," nonce = random(SecretBox.NONCE_SIZE)\n"," return box.encrypt(data, nonce)\n","\n","# ================= IMAGE UTILS =================\n","def bytes_to_pil(b):\n"," return Image.open(io.BytesIO(b)).convert(\"RGB\")\n","\n","def pil_to_bytes(img):\n"," buf = io.BytesIO()\n"," img.save(buf, format=\"PNG\")\n"," return buf.getvalue()\n","\n","# Parse resolution\n","res_map = {\n"," \"1024 x 1024 (Square)\": (1024, 1024),\n"," \"512 x 1024 (Portrait)\": (512, 1024),\n"," \"768 x 1024 (Slight Portrait)\": (768, 1024),\n"," \"1536 x 1024 (Landscape)\": (1536, 1024),\n"," \"2048 x 1024 (Wide Landscape)\": (2048, 1024),\n","}\n","target_width, target_height = res_map[resolution]\n","\n","reference_image_to_pair = Image.new(\"RGB\", (target_width, target_height), \"#181818\")\n","\n","# ================= LOAD DATASET =================\n","print(f\"๐Ÿ“ฆ Loading encrypted dataset: {encrypted_input_dataset_path}\")\n","input_dataset = load_from_disk(encrypted_input_dataset_path)\n","print(f\"โœ… Loaded {len(input_dataset)} encrypted samples\")\n","\n","# ================= CHECKPOINT HELPER =================\n","def save_checkpoint(batch_files, checkpoint_id):\n"," if not save_to_drive_every_n:\n"," return\n"," zip_path = f\"{checkpoint_folder}/checkpoint_{checkpoint_id}.zip\"\n"," tmp = f\"{checkpoint_folder}/tmp_{checkpoint_id}\"\n"," os.makedirs(tmp, exist_ok=True)\n"," for f in batch_files:\n"," shutil.copy(f, tmp)\n"," shutil.make_archive(zip_path.replace('.zip',''), 'zip', tmp)\n"," shutil.rmtree(tmp)\n"," print(f\"๐Ÿ’พ Checkpoint saved: {zip_path}\")\n","\n","# ================= INFERENCE LOOP =================\n","print(\"\\n๐Ÿš€ Starting encrypted multi-image inference...\")\n","\n","output_dataset_records = []\n","batch_outputs = []\n","checkpoint_id = 0\n","\n","for i, item in enumerate(input_dataset):\n"," gc.collect()\n"," torch.cuda.empty_cache()\n","\n"," enc_bytes = item[\"image_encrypted\"]\n"," dec_bytes = decrypt_bytes(enc_bytes)\n"," input_image = bytes_to_pil(dec_bytes)\n","\n"," if debug:\n"," print(f\" [{i+1}/{len(input_dataset)}] Input size: {input_image.size}\")\n","\n"," # Resize if needed\n"," if max(input_image.width, input_image.height) > max_image_dimension:\n"," aspect = input_image.width / input_image.height\n"," if input_image.width > input_image.height:\n"," new_w = max_image_dimension\n"," new_h = int(max_image_dimension / aspect)\n"," else:\n"," new_h = max_image_dimension\n"," new_w = int(max_image_dimension * aspect)\n"," input_image = input_image.resize((new_w, new_h), Image.LANCZOS)\n","\n"," reference_images = [input_image, reference_image_to_pair]\n","\n"," result = pipe(\n"," prompt=edit_prompt,\n"," image=reference_images,\n"," height=target_height,\n"," width=target_width,\n"," guidance_scale=1.0,\n"," num_inference_steps=4,\n"," generator=torch.Generator(\"cuda\").manual_seed(42),\n"," output_type=\"pil\",\n"," ).images[0]\n","\n"," out_bytes = pil_to_bytes(result)\n"," enc_out = encrypt_bytes(out_bytes)\n","\n"," out_path = os.path.join(output_folder, f\"edited_{i}.enc\")\n"," with open(out_path, \"wb\") as f:\n"," f.write(enc_out)\n","\n"," output_dataset_records.append({\"image_encrypted\": enc_out})\n"," batch_outputs.append(out_path)\n","\n"," print(f\"[{i+1}/{len(input_dataset)}] processed\")\n","\n"," if save_to_drive_every_n and len(batch_outputs) >= save_every_n:\n"," checkpoint_id += 1\n"," save_checkpoint(batch_outputs, checkpoint_id)\n"," batch_outputs = []\n","\n","if save_to_drive_every_n and len(batch_outputs) > 0:\n"," checkpoint_id += 1\n"," save_checkpoint(batch_outputs, checkpoint_id)\n","\n","print(\"\\nโœ… BATCH COMPLETE!\")\n","\n","output_dataset = Dataset.from_list(output_dataset_records)\n","output_dataset_path = \"/content/encrypted_output_dataset\"\n","output_dataset.save_to_disk(output_dataset_path)\n","print(f\"๐Ÿ“ฆ Encrypted output dataset saved: {output_dataset_path}\")\n","\n","timestamp = datetime.datetime.now().strftime(\"%Y%m%d_%H%M%S\")\n","final_zip = f\"/content/drive/MyDrive/klein_encrypted_outputs_{timestamp}.zip\"\n","shutil.make_archive(final_zip.replace('.zip',''), 'zip', output_folder)\n","print(f\"๐Ÿ“ฆ Final encrypted outputs ZIP โ†’ {final_zip}\")\n","print(\"๐ŸŽฏ Session B finished โ€“ ready for Session C\")"],"metadata":{"cellView":"form","id":"P1dwJTGSDIA-"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# Cell 5B\n","# Clean unassigned junk files from VRAM , run this if interrupting the cell script\n","# This cell is useful incase I interrupt cell 4\n","import torch , gc\n","torch.cuda.empty_cache()\n","gc.collect()"],"metadata":{"id":"e46WUV7jMInu","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1777213657366,"user_tz":-120,"elapsed":994,"user":{"displayName":"fukU Google","userId":"02763165356193834046"}},"outputId":"b534b8c5-c09a-4b42-aa6c-1efcf685490a"},"execution_count":9,"outputs":[{"output_type":"execute_result","data":{"text/plain":["1457"]},"metadata":{},"execution_count":9}]},{"cell_type":"code","source":["# ================================================\n","#@title ๐Ÿ”Œ End Session B. Auto Disconnect Colab Session (optional)\n","# ================================================\n","enable = False #@param {type:'boolean'}\n","if enable:\n"," print(\"๐Ÿ”Œ Disconnecting Colab session in 3 seconds...\")\n"," import time\n"," time.sleep(3)\n"," from google.colab import runtime\n"," runtime.unassign()\n"," print(\"Session disconnected.\")"],"metadata":{"cellView":"form","id":"kN2h-2bkDO8g"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# Session C , Decrypt a dataset"],"metadata":{"id":"dTwnU7KYzY2J"}},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 1C**: Mount Drive + HF auth + Install dependencies\n","# =============================================================================\n","# Same setup as previous sessions.\n","from google.colab import drive, userdata\n","from huggingface_hub import login\n","import torch\n","import os\n","import gc\n","import shutil\n","\n","drive.mount('/content/drive')\n","\n","hf_token = userdata.get('HF_TOKEN')\n","if hf_token:\n"," login(token=hf_token)\n","else:\n"," print(\"โš ๏ธ No HF_TOKEN found in secrets.\")\n","\n","print(\"๐Ÿงน Removing old diffusers...\")\n","!pip uninstall -y diffusers > /dev/null 2>&1\n","!rm -rf /usr/local/lib/python3.12/dist-packages/diffusers* ~/.cache/pip/*diffusers*\n","\n","print(\"๐Ÿ”„ Installing latest diffusers...\")\n","!pip install -q git+https://github.com/huggingface/diffusers.git --force-reinstall --no-deps\n","!python -m pip cache purge\n","\n","print(\"๐Ÿ” Installing encryption + datasets...\")\n","!pip install -q pynacl datasets\n","\n","print(\"โœ… Cell 1C complete!\")"],"metadata":{"cellView":"form","id":"pqeZgcSeDWUm","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1777213778608,"user_tz":-120,"elapsed":75494,"user":{"displayName":"fukU Google","userId":"02763165356193834046"}},"outputId":"962b2da4-0f1c-4ebd-fa3f-3851cc441d2f"},"execution_count":1,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n","๐Ÿงน Removing old diffusers...\n","๐Ÿ”„ Installing latest diffusers...\n"," Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n"," Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n"," Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n"," Building wheel for diffusers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n","Files removed: 6\n","๐Ÿ” Installing encryption + datasets...\n","\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m1.4/1.4 MB\u001b[0m \u001b[31m24.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hโœ… Cell 1C complete!\n"]}]},{"cell_type":"code","source":["# =============================================================================\n","#@markdown # **CELL 2C**: Decrypt dataset / checkpoints / ZIP โ†’ final images ZIP\n","# =============================================================================\n","# Choose one mode with the checkboxes. Outputs a clean ZIP of decrypted images.\n","# Supports all checkpoints (default), dataset, or single ZIP.\n","import os\n","import zipfile\n","import io\n","import hashlib\n","from PIL import Image\n","from nacl.secret import SecretBox\n","from datasets import load_from_disk\n","from google.colab import files\n","\n","# ================= MODE CONTROLS =================\n","process_all_checkpoints = True #@param {type:\"boolean\"}\n","decrypt_from_dataset = False #@param {type:\"boolean\"}\n","decrypt_from_zip = False #@param {type:\"boolean\"}\n","upload_zip_manually = False #@param {type:\"boolean\"}\n","download_output_zip = True #@param {type:\"boolean\"}\n","\n","dataset_to_decrypt = \"/content/encrypted_output_dataset\" #@param {type:\"string\"}\n","encrypted_zip_path = \"/content/drive/MyDrive/klein_checkpoints/checkpoint_2.zip\" #@param {type:\"string\"}\n","output_zip_name = \"decrypted_results.zip\" #@param {type:\"string\"}\n","\n","image_format = \"JPG\" #@param [\"PNG\", \"JPG\"]\n","\n","output_base_folder = \"/content/zip_outputs\"\n","os.makedirs(output_base_folder, exist_ok=True)\n","checkpoint_dir = \"/content/drive/MyDrive/klein_checkpoints\"\n","\n","debug = False #@param {type:\"boolean\"}\n","\n","# ================= ๐Ÿ”‘ KEY =================\n","decryption_password = \"banana\" #@param {type:\"string\"}\n","def derive_key(password):\n"," return hashlib.sha256(password.encode()).digest()\n","\n","SECRET_KEY = derive_key(decryption_password)\n","box = SecretBox(SECRET_KEY)\n","\n","def decrypt_bytes(enc):\n"," return box.decrypt(enc)\n","\n","# ================= IMAGE IO =================\n","def bytes_to_pil(b):\n"," return Image.open(io.BytesIO(b)).convert(\"RGB\")\n","\n","# ================= DECRYPT HELPERS =================\n","def decrypt_stream(enc_bytes_list):\n"," out = []\n"," for enc in enc_bytes_list:\n"," dec = decrypt_bytes(enc)\n"," out.append(bytes_to_pil(dec))\n"," return out\n","\n","def decrypt_zip(zip_path):\n"," with zipfile.ZipFile(zip_path, \"r\") as z:\n"," enc_files = [z.read(n) for n in z.namelist() if n.endswith(\".enc\")]\n"," return decrypt_stream(enc_files)\n","\n","def decrypt_dataset(ds):\n"," return decrypt_stream([x[\"image_encrypted\"] for x in ds])\n","\n","# ================= ZIP BUILDER =================\n","def write_images_to_zip(image_pil_list, out_zip_path, fmt):\n"," with zipfile.ZipFile(out_zip_path, \"w\", compression=zipfile.ZIP_DEFLATED) as zf:\n"," ext = \"png\" if fmt == \"PNG\" else \"jpg\"\n"," for i, img in enumerate(image_pil_list):\n"," buf = io.BytesIO()\n"," if fmt == \"JPG\":\n"," img.save(buf, format=\"JPEG\", quality=95, optimize=True)\n"," else:\n"," img.save(buf, format=fmt)\n"," zf.writestr(f\"{i:05d}.{ext}\", buf.getvalue())\n","\n","# ================= OUTPUT BUFFER =================\n","all_image_pil = []\n","\n","# =============================================================================\n","# ๐Ÿ”ฅ MODE 1: ALL CHECKPOINTS (recommended)\n","# =============================================================================\n","if process_all_checkpoints:\n"," print(f\"๐Ÿ“‚ Scanning checkpoints in: {checkpoint_dir}\")\n"," checkpoint_zips = sorted([\n"," os.path.join(checkpoint_dir, f)\n"," for f in os.listdir(checkpoint_dir)\n"," if f.endswith(\".zip\") and \"checkpoint\" in f\n"," ])\n"," print(f\"๐Ÿ” Found {len(checkpoint_zips)} checkpoint ZIPs\")\n"," for idx, zpath in enumerate(checkpoint_zips):\n"," if debug:\n"," print(f\" Processing {zpath}\")\n"," imgs = decrypt_zip(zpath)\n"," all_image_pil.extend(imgs)\n","\n","# =============================================================================\n","# ๐Ÿ”“ MODE 2: ENCRYPTED DATASET\n","# =============================================================================\n","elif decrypt_from_dataset:\n"," print(f\"๐Ÿ“ฆ Loading dataset: {dataset_to_decrypt}\")\n"," ds = load_from_disk(dataset_to_decrypt)\n"," imgs = decrypt_dataset(ds)\n"," all_image_pil.extend(imgs)\n","\n","# =============================================================================\n","# ๐Ÿ”“ MODE 3: SINGLE ZIP\n","# =============================================================================\n","elif decrypt_from_zip:\n"," if upload_zip_manually:\n"," print(\"๐Ÿ“ค Please upload your encrypted ZIP now...\")\n"," uploaded = files.upload()\n"," zip_name = list(uploaded.keys())[0]\n"," zip_path = \"/content/\" + zip_name\n"," with open(zip_path, \"wb\") as f:\n"," f.write(uploaded[zip_name])\n"," else:\n"," zip_path = encrypted_zip_path\n"," print(f\"๐Ÿ“ฆ Decrypting single ZIP: {zip_path}\")\n"," imgs = decrypt_zip(zip_path)\n"," all_image_pil.extend(imgs)\n","\n","# =============================================================================\n","# ๐Ÿ“ฆ FINAL PACKAGING\n","# =============================================================================\n","if download_output_zip and all_image_pil:\n"," final_zip = os.path.join(output_base_folder, output_zip_name)\n"," print(f\"๐Ÿ“ฆ Building final {image_format} ZIP with {len(all_image_pil)} images โ†’ {final_zip}\")\n"," write_images_to_zip(all_image_pil, final_zip, image_format)\n"," files.download(final_zip)\n"," print(\"โฌ‡๏ธ Download started via google.colab.files.download\")\n","else:\n"," print(\"โœ… Decryption complete โ€“ no download requested.\")\n","\n","print(\"๐ŸŽฏ Session C finished!\")"],"metadata":{"cellView":"form","id":"puoG9y2nDZn3"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"a7rdpSwVz0ZX"},"outputs":[],"source":["# ================================================\n","#@title ๐Ÿ”Œ End session C. Auto Disconnect Colab Session\n","# ================================================\n","\n","enable = False #@param {type:'boolean'}\n","if enable:\n"," print(\"๐Ÿ”Œ Disconnecting Colab session in 3 seconds...\")\n"," import time\n"," time.sleep(3)\n","\n"," from google.colab import runtime\n"," runtime.unassign()\n","\n"," print(\"Session disconnected.\")"]},{"cell_type":"markdown","source":["# Select Klein processed file to use next"],"metadata":{"id":"s7R3l3-pY5W7"}},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"id":"ijzwEoboHVPR"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"OdcEXFs4oBt_","cellView":"form"},"outputs":[],"source":["import os\n","\n","klein_edited_zip_path = '/content/drive/MyDrive/klein_processed.zip' #@param {type:'string'}\n","zip_path = klein_edited_zip_path\n","\n","if not os.path.exists(zip_path):\n"," raise FileNotFoundError(f\"โŒ Klein edited zip file not found:\\n{zip_path}\\n\\nPlease ensure the path is correct and the file exists in your Drive.\")"]},{"cell_type":"markdown","source":["# โš™๏ธ Create 1024x1024 frames from selected klein edited set"],"metadata":{"id":"4PjK9a8Sni3A"}},{"cell_type":"code","source":["#@title ๐Ÿ–ผ๏ธ **Image Background Processor (v1)**\n","#@markdown ---\n","#@markdown ## Enable Processor V1\n","enable_processor_v1 = False #@param {type:\"boolean\"}\n","\n","#@title ๐Ÿ–ผ๏ธ **Image Background Processor**\n","#(v2 - Solid #181818 Flood-Fill + Auto-Clear)\n","#**Crop left/right empty space + Convert *any* gray background to exact #181818**\n","#@markdown ---\n","#**New**: Automatically clears all previous processed images on re-run\n","#(no more mixing old files when you run again)\n","\n","#Run this cell (Shift + Enter)\n","#Fill the form below\n","#Click **Run**\n","\n","# ==================== FORM PARAMETERS ====================\n","\n","#input_zip_path = \"/content/drive/MyDrive/klein_processed.zip\" #@param {type:\"string\", placeholder:\"Paste full path to your ZIP file here\"}\n","input_zip_path = zip_path\n","\n","tolerance_crop = 50 #@param {type:\"slider\", min:0, max:100, step:1, title:\"๐ŸŸฆ Crop Tolerance (higher = more aggressive cropping)\"}\n","\n","bg_replace_threshold = 20 #@param {type:\"slider\", min:10, max:100, step:1}\n","\n","force_remount = False #@param {type:\"boolean\", title:\"๐Ÿ”„ Force remount Drive (recommended)\"}\n","\n","#@markdown ---\n","\n","\n","if enable_processor_v1:\n"," from google.colab import drive\n"," import zipfile\n"," import os\n"," import shutil # โ† NEW for clearing folders\n"," from PIL import Image\n"," from collections import deque\n","\n"," # ========================= CONFIG =========================\n"," TARGET_GRAY = (24, 24, 24) # Exact #181818 - do not change\n"," # =======================================================\n","\n"," print(\"๐Ÿš€ Starting image processor (Solid Background v2 + Auto-Clear)...\")\n","\n"," # 1. Mount Google Drive\n"," drive.mount('/content/drive', force_remount=force_remount)\n","\n"," # 2. Validate ZIP path\n"," if not input_zip_path or not os.path.exists(input_zip_path):\n"," raise FileNotFoundError(f\"โŒ ZIP file not found:\\n{input_zip_path}\\n\\nPlease paste the correct full path (e.g. /content/drive/MyDrive/my_photos.zip)\")\n","\n"," print(f\"โœ… ZIP found: {input_zip_path}\")\n","\n"," # 3. Define working folders\n"," extract_dir = '/content/extracted_images'\n"," processed_dir = '/content/processed_images'\n","\n"," # === NEW: Clear previous processed & extracted images on every run ===\n"," for directory in [extract_dir, processed_dir]:\n"," if os.path.exists(directory):\n"," shutil.rmtree(directory)\n"," print(f\"๐Ÿงน Cleared old folder: {directory}\")\n"," os.makedirs(extract_dir, exist_ok=True)\n"," os.makedirs(processed_dir, exist_ok=True)\n"," print(\"โœ… Fresh folders ready\")\n","\n"," # 4. Unzip\n"," print(\"๐Ÿ“ฆ Unzipping...\")\n"," with zipfile.ZipFile(input_zip_path, 'r') as zip_ref:\n"," zip_ref.extractall(extract_dir)\n"," print(f\"โœ… Unzipped to {extract_dir}\")\n","\n"," # ==================== HELPER 1: Crop only left & right ====================\n"," def crop_left_right(img):\n"," if img.mode != 'RGB':\n"," img = img.convert('RGB')\n","\n"," width, height = img.size\n"," bg_color = img.getpixel((0, 0))\n","\n"," left = width\n"," right = 0\n","\n"," for x in range(width):\n"," column_is_empty = True\n"," for y in range(height):\n"," px = img.getpixel((x, y))\n"," if any(abs(a - b) > tolerance_crop for a, b in zip(px, bg_color)):\n"," column_is_empty = False\n"," break\n"," if not column_is_empty:\n"," left = min(left, x)\n"," right = max(right, x)\n","\n"," if left >= right:\n"," return img\n","\n"," return img.crop((left, 0, right + 1, height))\n","\n"," # ==================== HELPER 2: FLOOD-FILL BACKGROUND FROM EDGES ====================\n"," def adjust_background(img, original_bg_color):\n"," if img.mode != 'RGB':\n"," img = img.convert('RGB')\n","\n"," width, height = img.size\n"," pixels = img.load()\n"," threshold = bg_replace_threshold\n","\n"," visited = set()\n"," queue = deque()\n"," directions = [(dx, dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1] if not (dx == 0 and dy == 0)]\n","\n"," # Seed from borders\n"," for x in range(width):\n"," for y in (0, height - 1):\n"," if (x, y) not in visited:\n"," px = pixels[x, y]\n"," dist = ((px[0] - original_bg_color[0])**2 + (px[1] - original_bg_color[1])**2 + (px[2] - original_bg_color[2])**2) ** 0.5\n"," if dist <= threshold:\n"," queue.append((x, y))\n"," visited.add((x, y))\n"," pixels[x, y] = TARGET_GRAY\n","\n"," for y in range(height):\n"," for x in (0, width - 1):\n"," if (x, y) not in visited:\n"," px = pixels[x, y]\n"," dist = ((px[0] - original_bg_color[0])**2 + (px[1] - original_bg_color[1])**2 + (px[2] - original_bg_color[2])**2) ** 0.5\n"," if dist <= threshold:\n"," queue.append((x, y))\n"," visited.add((x, y))\n"," pixels[x, y] = TARGET_GRAY\n","\n"," # Flood fill\n"," while queue:\n"," x, y = queue.popleft()\n"," for dx, dy in directions:\n"," nx, ny = x + dx, y + dy\n"," if 0 <= nx < width and 0 <= ny < height and (nx, ny) not in visited:\n"," px = pixels[nx, ny]\n"," dist = ((px[0] - original_bg_color[0])**2 + (px[1] - original_bg_color[1])**2 + (px[2] - original_bg_color[2])**2) ** 0.5\n"," if dist <= threshold:\n"," visited.add((nx, ny))\n"," pixels[nx, ny] = TARGET_GRAY\n"," queue.append((nx, ny))\n","\n"," return img\n","\n"," # 5. Process every image\n"," print(\"๐Ÿ–ผ๏ธ Processing images...\")\n"," image_extensions = ('.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.webp')\n","\n"," processed_count = 0\n"," for filename in os.listdir(extract_dir):\n"," if filename.lower().endswith(image_extensions):\n"," img_path = os.path.join(extract_dir, filename)\n"," try:\n"," with Image.open(img_path) as original_img:\n"," cropped = crop_left_right(original_img)\n"," orig_bg = original_img.getpixel((0, 0))\n"," processed = adjust_background(cropped, orig_bg)\n","\n"," out_path = os.path.join(processed_dir, filename)\n"," processed.save(out_path, quality=95 if filename.lower().endswith(('.jpg', '.jpeg')) else None)\n","\n"," processed_count += 1\n"," print(f\" โœ… {filename}\")\n"," except Exception as e:\n"," print(f\" โŒ Skipped {filename}: {e}\")\n","\n"," print(f\"\\n๐ŸŽ‰ Processed {processed_count} images!\")\n","\n"," # 6. Create final ZIP in Drive\n"," output_zip_name = \"PROCESSED_\" + os.path.basename(zip_path)\n"," output_zip_path = os.path.join(os.path.dirname(zip_path), output_zip_name)\n"," zip_path = output_zip_path\n","\n"," print(f\"๐Ÿ“ฆ Creating final ZIP: {output_zip_name}\")\n"," with zipfile.ZipFile(output_zip_path, 'w', zipfile.ZIP_DEFLATED) as zip_out:\n"," for root, _, files in os.walk(processed_dir):\n"," for file in files:\n"," file_path = os.path.join(root, file)\n"," arcname = os.path.relpath(file_path, processed_dir)\n"," zip_out.write(file_path, arcname)\n","\n"," print(\"\\nโœ… ALL DONE! Solid #181818 background achieved.\")\n"," print(f\"๐Ÿ“ Saved to your Drive at:\\n {output_zip_path}\")\n"],"metadata":{"id":"HN4kta-OpZ4W","cellView":"form"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["#@title **๐Ÿ–ผ๏ธ Image Background Processor V2 (WIP)**\n","#@markdown ---\n","#@markdown ## Enable Processor V2\n","enable_processor_v2 = True #@param {type:\"boolean\"}\n","\n","#@title **๐Ÿ–ผ๏ธ Image Background Processor V2 (WIP)**\n","#(v2.7 - **Inverse speck removal** + Border-protected forward speck + % Margin + Solid #181818)\n","\n","#**Crop left/right empty space + Convert *any* gray background to exact #181818**\n","#**New in v2.7**:\n","# โ€ข **Inverse speck removal**: finds tiny foreground (subject-colored) specks/islands inside the background and replaces them with solid #181818\n","# โ€ข Forward speck removal (previous) still protects any #181818 connected to the outer image edge\n","# โ€ข Anti-aliasing is guaranteed to be the **very last step** (after both forward + inverse speck removal)\n","# โ€ข All previous features (4-corner BG, % margin, checkboxes, distance-based enclosed speck removal) unchanged\n","\n","# ==================== FORM PARAMETERS ====================\n","\n","input_zip_path = zip_path\n","\n","tolerance_crop = 60 #@param {type:\"slider\", min:0, max:100, step:1, title:\"๐Ÿ”ต Crop Tolerance (higher = more aggressive cropping)\"}\n","\n","bg_replace_threshold = 10 #@param {type:\"slider\", min:10, max:100, step:1, title:\"๐ŸŽจ Legacy absolute threshold (kept for compatibility)\"}\n","\n","# โ”€โ”€ % Margin for BG color estimation โ”€โ”€\n","bg_margin_percent = 6 #@param {type:\"slider\", min:0, max:50, step:1, title:\"% Margin for BG color estimation (wider = more tolerant to inner-loop gray variations)\"}\n","\n","# โ”€โ”€ Feature Checkboxes โ”€โ”€\n","enable_robust_bg_detection = True #@param {type:\"boolean\", title:\"โœ… Use 4-corner robust BG color (best for inner loops)\"}\n","enable_floodfill_background_adjustment = True #@param {type:\"boolean\", title:\"โœ… Enable solid #181818 background replacement\"}\n","enable_small_speck_removal = True #@param {type:\"boolean\"}\n","#title:\"โœ… Forward speck removal: remove tiny #181818 specks on subject\"}\n","enable_inverse_speck_removal = True #@param {type:\"boolean\"}\n","#title:\"โœ… Inverse speck removal: fill tiny subject specks inside background with #181818\"}\n","enable_anti_aliasing = True #@param {type:\"boolean\", title:\"โœ… Smooth edges (Gaussian anti-aliasing)\"}\n","\n","anti_aliasing_strength = 6 #@param {type:\"slider\", min:1, max:40, step:1, title:\" โ†ณ Anti-aliasing Strength (pixels to blend)\"}\n","\n","# โ”€โ”€ Forward speck removal (enclosed only) โ”€โ”€\n","min_floodfill_steps = 8 #@param {type:\"slider\", min:1, max:20, step:1, title:\" โ†ณ Min floodfill steps to foreground (N) for ENCLOSED BG only (outer-edge-connected BG always protected)\"}\n","\n","# โ”€โ”€ Inverse speck removal โ”€โ”€\n","max_inverse_speck_size = 10 #@param {type:\"slider\", min:1, max:100, step:1, title:\" โ†ณ Max size of foreground specks to fill with #181818\"}\n","\n","force_remount = False #@param {type:\"boolean\", title:\"๐Ÿ”„ Force remount Drive\"}\n","\n","#@markdown ---\n","\n","\n","if enable_processor_v2:\n"," from google.colab import drive\n"," import zipfile\n"," import os\n"," import shutil\n"," from PIL import Image, ImageFilter\n"," from collections import deque\n","\n"," # ========================= CONFIG =========================\n"," TARGET_GRAY = (24, 24, 24) # Exact #181818\n"," # =======================================================\n","\n"," print(\"๐Ÿš€ Starting Image Background Processor v2.7 (Forward + Inverse speck removal)...\")\n","\n"," # 1. Mount Google Drive\n"," drive.mount('/content/drive', force_remount=force_remount)\n","\n"," # 2. Validate ZIP path\n"," if not input_zip_path or not os.path.exists(input_zip_path):\n"," raise FileNotFoundError(f\"โŒ ZIP file not found:\\n{input_zip_path}\\n\\nPlease paste the correct full path\")\n","\n"," print(f\"โœ… ZIP found: {input_zip_path}\")\n","\n"," # 3. Define working folders\n"," extract_dir = '/content/extracted_images'\n"," processed_dir = '/content/processed_images'\n","\n"," # Clear previous runs\n"," for directory in [extract_dir, processed_dir]:\n"," if os.path.exists(directory):\n"," shutil.rmtree(directory)\n"," print(f\"๏น… Cleared old folder: {directory}\")\n"," os.makedirs(extract_dir, exist_ok=True)\n"," os.makedirs(processed_dir, exist_ok=True)\n"," print(\"โœ… Fresh folders ready\")\n","\n"," # 4. Unzip\n"," print(\"๐Ÿš€ Unzipping...\")\n"," with zipfile.ZipFile(input_zip_path, 'r') as zip_ref:\n"," zip_ref.extractall(extract_dir)\n"," print(f\"โœ… Unzipped to {extract_dir}\")\n","\n"," # ==================== HELPER 1: Crop only left & right ====================\n"," def crop_left_right(img):\n"," if img.mode != 'RGB':\n"," img = img.convert('RGB')\n"," width, height = img.size\n"," bg_color = img.getpixel((0, 0))\n"," left = width\n"," right = 0\n"," for x in range(width):\n"," column_is_empty = True\n"," for y in range(height):\n"," px = img.getpixel((x, y))\n"," if any(abs(a - b) > tolerance_crop for a, b in zip(px, bg_color)):\n"," column_is_empty = False\n"," break\n"," if not column_is_empty:\n"," left = min(left, x)\n"," right = max(right, x)\n"," if left >= right:\n"," return img\n"," return img.crop((left, 0, right + 1, height))\n","\n"," # ==================== HELPER 2: FULL BACKGROUND PROCESSOR (v2.7) ====================\n"," def adjust_background(img, original_bg_color,\n"," enable_floodfill_background_adjustment,\n"," enable_small_speck_removal,\n"," enable_inverse_speck_removal,\n"," enable_anti_aliasing,\n"," anti_aliasing_strength,\n"," min_floodfill_steps,\n"," max_inverse_speck_size,\n"," bg_margin_percent):\n"," if img.mode != 'RGB':\n"," img = img.convert('RGB')\n","\n"," width, height = img.size\n"," pixels_access = img.load()\n"," target_gray = TARGET_GRAY\n"," directions = [(dx, dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1] if not (dx == 0 and dy == 0)]\n","\n"," # 1. Identify foreground using % margin\n"," per_channel_margin = int(255 * (bg_margin_percent / 100.0))\n"," is_foreground = [[False for _ in range(height)] for _ in range(width)]\n"," for y in range(height):\n"," for x in range(width):\n"," px = pixels_access[(x, y)]\n"," is_bg = all(abs(px[i] - original_bg_color[i]) <= per_channel_margin for i in range(3))\n"," if not is_bg:\n"," is_foreground[x][y] = True\n","\n"," # 2. Base image: solid #181818 + foreground\n"," base_processed_img = Image.new(\"RGB\", (width, height), target_gray)\n"," base_processed_pixels = base_processed_img.load()\n"," for y in range(height):\n"," for x in range(width):\n"," if is_foreground[x][y]:\n"," base_processed_pixels[(x, y)] = pixels_access[(x, y)]\n","\n"," # 3. Forward speck removal (border-protected, enclosed only)\n"," if enable_floodfill_background_adjustment and enable_small_speck_removal:\n"," print(\" ๐Ÿ” Running forward speck removal (border-protected)...\")\n"," refined_img = base_processed_img.copy()\n"," refined_pixels = refined_img.load()\n","\n"," # Mark border-connected #181818\n"," connected_to_border = [[False] * height for _ in range(width)]\n"," queue = deque()\n"," for x in range(width):\n"," for y_border in [0, height-1]:\n"," if refined_pixels[(x, y_border)] == target_gray and not connected_to_border[x][y_border]:\n"," connected_to_border[x][y_border] = True\n"," queue.append((x, y_border))\n"," for y in range(height):\n"," for x_border in [0, width-1]:\n"," if refined_pixels[(x_border, y)] == target_gray and not connected_to_border[x_border][y]:\n"," connected_to_border[x_border][y] = True\n"," queue.append((x_border, y))\n"," while queue:\n"," cx, cy = queue.popleft()\n"," for dx, dy in directions:\n"," nx, ny = cx + dx, cy + dy\n"," if 0 <= nx < width and 0 <= ny < height and not connected_to_border[nx][ny] and refined_pixels[(nx, ny)] == target_gray:\n"," connected_to_border[nx][ny] = True\n"," queue.append((nx, ny))\n","\n"," # Distance to foreground (for enclosed BG only)\n"," distance = [[-1] * height for _ in range(width)]\n"," queue = deque()\n"," for y in range(height):\n"," for x in range(width):\n"," if is_foreground[x][y]:\n"," for dx, dy in directions:\n"," nx, ny = x + dx, y + dy\n"," if 0 <= nx < width and 0 <= ny < height and not is_foreground[nx][ny] and distance[nx][ny] == -1:\n"," distance[nx][ny] = 1\n"," queue.append((nx, ny))\n"," break\n"," while queue:\n"," cx, cy = queue.popleft()\n"," for dx, dy in directions:\n"," nx, ny = cx + dx, cy + dy\n"," if 0 <= nx < width and 0 <= ny < height and not is_foreground[nx][ny] and distance[nx][ny] == -1:\n"," distance[nx][ny] = distance[cx][cy] + 1\n"," queue.append((nx, ny))\n","\n"," # Revert only enclosed + too-close BG pixels\n"," for y in range(height):\n"," for x in range(width):\n"," if refined_pixels[(x, y)] == target_gray:\n"," if not connected_to_border[x][y] and (distance[x][y] == -1 or distance[x][y] < min_floodfill_steps):\n"," refined_pixels[(x, y)] = pixels_access[(x, y)]\n","\n"," base_processed_img = refined_img\n"," base_processed_pixels = base_processed_img.load()\n","\n"," # 4. INVERSE speck removal (tiny foreground specks inside background โ†’ #181818)\n"," if enable_floodfill_background_adjustment and enable_inverse_speck_removal:\n"," print(\" ๐Ÿ” Running inverse speck removal (small FG specks โ†’ #181818)...\")\n"," refined_img = base_processed_img.copy()\n"," refined_pixels = refined_img.load()\n"," visited = [[False] * height for _ in range(width)]\n","\n"," for y in range(height):\n"," for x in range(width):\n"," if refined_pixels[(x, y)] != target_gray and not visited[x][y]:\n"," component = []\n"," queue = deque([(x, y)])\n"," visited[x][y] = True\n"," while queue:\n"," cx, cy = queue.popleft()\n"," component.append((cx, cy))\n"," for dx, dy in directions:\n"," nx, ny = cx + dx, cy + dy\n"," if 0 <= nx < width and 0 <= ny < height and not visited[nx][ny] and refined_pixels[(nx, ny)] != target_gray:\n"," visited[nx][ny] = True\n"," queue.append((nx, ny))\n"," # Fill small foreground specks with solid #181818\n"," if len(component) < max_inverse_speck_size:\n"," for px, py in component:\n"," refined_pixels[(px, py)] = target_gray\n","\n"," base_processed_img = refined_img\n"," base_processed_pixels = base_processed_img.load()\n","\n"," # 5. Anti-aliasing โ€“ ALWAYS LAST (as requested)\n"," if not enable_anti_aliasing:\n"," return base_processed_img\n","\n"," mask = Image.new(\"L\", (width, height), 0)\n"," mask_pixels = mask.load()\n"," for y in range(height):\n"," for x in range(width):\n"," if base_processed_pixels[(x, y)] != target_gray:\n"," mask_pixels[(x, y)] = 255\n","\n"," blur_radius = anti_aliasing_strength / 2.0\n"," blurred_mask = mask.filter(ImageFilter.GaussianBlur(radius=blur_radius))\n","\n"," solid_bg = Image.new(\"RGB\", (width, height), target_gray)\n"," final_img_with_aa = Image.composite(base_processed_img, solid_bg, blurred_mask)\n","\n"," return final_img_with_aa\n","\n"," # ==================== MAIN PROCESSING LOOP ====================\n"," print(\"๐Ÿš€ Processing images...\")\n"," image_extensions = ('.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.webp')\n","\n"," processed_count = 0\n"," for filename in os.listdir(extract_dir):\n"," if filename.lower().endswith(image_extensions):\n"," img_path = os.path.join(extract_dir, filename)\n"," try:\n"," with Image.open(img_path) as original_img:\n"," # === ROBUST BACKGROUND COLOR DETECTION ===\n"," cropped = crop_left_right(original_img)\n"," if cropped.mode != 'RGB':\n"," cropped = cropped.convert('RGB')\n","\n"," if enable_robust_bg_detection:\n"," w, h = cropped.size\n"," samples = [\n"," cropped.getpixel((0, 0)),\n"," cropped.getpixel((w-1, 0)),\n"," cropped.getpixel((0, h-1)),\n"," cropped.getpixel((w-1, h-1))\n"," ]\n"," orig_bg = tuple(sum(c) // len(samples) for c in zip(*samples))\n"," print(f\" ๐Ÿ“ Using robust 4-corner BG color for {filename}\")\n"," else:\n"," orig_bg = cropped.getpixel((0, 0))\n","\n"," # === PROCESS IMAGE ===\n"," if enable_floodfill_background_adjustment:\n"," processed = adjust_background(\n"," cropped,\n"," orig_bg,\n"," enable_floodfill_background_adjustment,\n"," enable_small_speck_removal,\n"," enable_inverse_speck_removal,\n"," enable_anti_aliasing,\n"," anti_aliasing_strength,\n"," min_floodfill_steps,\n"," max_inverse_speck_size,\n"," bg_margin_percent\n"," )\n"," else:\n"," processed = cropped\n","\n"," out_path = os.path.join(processed_dir, filename)\n"," processed.save(out_path, quality=95 if filename.lower().endswith(('.jpg', '.jpeg')) else None)\n","\n"," processed_count += 1\n"," print(f\" โœ… {filename}\")\n","\n"," except Exception as e:\n"," print(f\" โŒ Skipped {filename}: {e}\")\n","\n"," print(f\"\\n๐ŸŽ‰ Processed {processed_count} images!\")\n","\n"," # 6. Create final ZIP\n"," output_zip_name = \"PROCESSED_\" + os.path.basename(input_zip_path)\n"," output_zip_path = os.path.join(os.path.dirname(input_zip_path), output_zip_name)\n","\n"," print(f\"๐Ÿš€ Creating final ZIP: {output_zip_name}\")\n"," with zipfile.ZipFile(output_zip_path, 'w', zipfile.ZIP_DEFLATED) as zip_out:\n"," for root, _, files in os.walk(processed_dir):\n"," for file in files:\n"," file_path = os.path.join(root, file)\n"," arcname = os.path.relpath(file_path, processed_dir)\n"," zip_out.write(file_path, arcname)\n","\n"," print(\"\\nโœ… ALL DONE! Solid #181818 everywhere (forward + inverse specks cleaned) + smooth AA last\")\n"," print(f\"๐Ÿ“ Saved to your Drive at:\\n {output_zip_path}\")\n"],"metadata":{"cellView":"form","id":"tFGWg7jNv4mo"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# โš™๏ธ Create composites"],"metadata":{"id":"kVAe29swHo4I"}},{"cell_type":"code","source":["#@markdown Set zip file input path for making composites\n","input_zip_path = \"/content/drive/MyDrive/PROCESSED_klein_processed.zip\" #@param {type:'string'}\n","zip_file_path = input_zip_path"],"metadata":{"id":"IXQKiBVrNPcE"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"93JpoQJ77NGu","cellView":"form"},"outputs":[],"source":["# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# ๐ŸŽจ CLEAN ROW โ†’ PURE 1024x1024 FRAMES (NO DISTORTION)\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","#@markdown ## โš™๏ธ Main Settings\n","num_frames = 100 #@param {type:\"slider\", min:10, max:2000, step:10}\n","overlap_percent = 0 #@param {type:\"slider\", min:0, max:50, step:1}\n","min_step_ratio = 0.8 #@param {type:\"slider\", min:0.5, max:1.0, step:0.05}\n","max_step_ratio = 1.0 #@param {type:\"slider\", min:0.8, max:1.5, step:0.05}\n","\n","#@markdown ## ๐Ÿงฑ Border\n","border_width = 8 #@param {type:\"slider\", min:0, max:100}\n","\n","#@markdown ## ๐Ÿ’พ Input / Output\n","save_to_google_drive = True #@param {type:\"boolean\"}\n","drive_folder_name = \"vertical_slices_output\" #@param {type:\"string\"}\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","FRAME_SIZE = 1024\n","INNER_SIZE = FRAME_SIZE - 2 * border_width\n","BORDER_COLOR = (24, 24, 24)\n","\n","import os, random, zipfile\n","import numpy as np\n","from PIL import Image\n","from google.colab import drive\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Mount Drive\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","drive_mounted = False\n","if save_to_google_drive:\n"," try:\n"," drive.mount('/content/drive', force_remount=False)\n"," drive_mounted = True\n"," drive_output_dir = os.path.join(\"/content/drive/MyDrive\", drive_folder_name)\n"," os.makedirs(drive_output_dir, exist_ok=True)\n"," print(\"Drive mounted\")\n"," except:\n"," save_to_google_drive = False\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Extract ZIP\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","extract_root = \"/content/extracted_images\"\n","output_dir = \"/content/frames\"\n","\n","os.makedirs(extract_root, exist_ok=True)\n","os.makedirs(output_dir, exist_ok=True)\n","\n","with zipfile.ZipFile(zip_file_path, 'r') as zf:\n"," zf.extractall(extract_root)\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Load images\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","valid_exts = ('.jpg','.jpeg','.png','.webp')\n","all_sources = []\n","\n","for root, _, files in os.walk(extract_root):\n"," for f in files:\n"," if f.lower().endswith(valid_exts):\n"," all_sources.append(os.path.join(root, f))\n","\n","print(\"Images found:\", len(all_sources))\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Build row UNTIL enough width\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","def build_row_until_width(all_sources, target_h, overlap_ratio, required_width):\n"," canvas = Image.new(\"RGB\", (required_width, target_h))\n"," x = 0\n","\n"," while x < required_width:\n"," src = random.choice(all_sources)\n","\n"," try:\n"," im = Image.open(src).convert(\"RGB\")\n"," w, h = im.size\n","\n"," scale = target_h / h\n"," new_w = int(w * scale)\n","\n"," im = im.resize((new_w, target_h), Image.LANCZOS)\n","\n"," # overlap\n"," if x > 0:\n"," x -= int(new_w * overlap_ratio)\n","\n"," canvas.paste(im, (x, 0))\n"," x += new_w\n","\n"," except:\n"," continue\n","\n"," return canvas\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Calculate required width\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","overlap_ratio = overlap_percent / 100.0\n","\n","avg_step = (min_step_ratio + max_step_ratio) / 2\n","estimated_width = int(num_frames * INNER_SIZE * avg_step * 1.2)\n","\n","print(\"Building row width:\", estimated_width)\n","\n","row_img = build_row_until_width(\n"," all_sources,\n"," INNER_SIZE,\n"," overlap_ratio,\n"," estimated_width\n",")\n","\n","row_np = np.array(row_img)\n","row_h, row_w = row_np.shape[:2]\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Generate frames (NO distortion)\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","frame_idx = 0\n","x_cursor = 0\n","\n","while x_cursor + INNER_SIZE <= row_w and frame_idx < num_frames:\n","\n"," step = random.randint(\n"," int(INNER_SIZE * min_step_ratio),\n"," int(INNER_SIZE * max_step_ratio)\n"," )\n","\n"," crop = row_np[:, x_cursor:x_cursor + INNER_SIZE]\n","\n"," final = Image.new(\"RGB\", (FRAME_SIZE, FRAME_SIZE), BORDER_COLOR)\n"," final.paste(Image.fromarray(crop), (border_width, border_width))\n","\n"," fname = f\"frame_{frame_idx:04d}.jpg\"\n"," final.save(os.path.join(output_dir, fname), \"JPEG\", quality=90)\n","\n"," frame_idx += 1\n"," x_cursor += step\n","\n"," if frame_idx % 50 == 0:\n"," print(frame_idx, \"frames done\")\n","\n","print(\"Finished:\", frame_idx)\n","\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","# Save ZIP\n","# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n","\n","if save_to_google_drive and drive_mounted:\n","\n"," zip_path = \"/content/output.zip\"\n"," drive_path = os.path.join(drive_output_dir, \"vertical_slices.zip\")\n","\n"," with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n"," for f in os.listdir(output_dir):\n"," if f.endswith(\".jpg\"):\n"," zf.write(os.path.join(output_dir, f), arcname=f)\n","\n"," !cp -f \"{zip_path}\" \"{drive_path}\"\n","\n"," print(\"Saved to Drive:\", drive_path)"]},{"cell_type":"markdown","source":["# Done!\n","\n","In the zip file /content/drive/MyDrive/vertical_slices_output/vertical_slices.zip , there you will find 100 image composites to choose for lora training\n","\n","//-----//"],"metadata":{"id":"tJlvhf9xDmA7"}}],"metadata":{"colab":{"provenance":[{"file_id":"https://huggingface.co/codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic/blob/main/run_klein_edit_aio.ipynb","timestamp":1777129973676},{"file_id":"https://huggingface.co/codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic/blob/main/notebooks/klein_edit_aio.ipynb","timestamp":1777127335701},{"file_id":"https://huggingface.co/codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic/blob/main/notebooks/klein_edit_aio.ipynb","timestamp":1776991571771},{"file_id":"https://huggingface.co/codeShare/FLUX.2-klein-AIO-SDNQ-4bit-dynamic/blob/main/notebooks/klein_edit_aio.ipynb","timestamp":1776952244463},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776905776793},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776904822796},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776896778295},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776814708184},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776796861814},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776795061697},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776794307247},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776790556621},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776789720072},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776787634021},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_prepare_lora_set.ipynb","timestamp":1776773678064},{"file_id":"151XI3nRFxLRbwRc8V6OfWyqp-zTnfySv","timestamp":1776764241991},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/klein_edit.ipynb","timestamp":1776702729526},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/vertical_slice_prepper.ipynb","timestamp":1776687886662},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/vertical_slice_prepper.ipynb","timestamp":1776366149549},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/lora_vertical_slice_dataset_creator.ipynb","timestamp":1776287741995},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/lora_vertical_slice_dataset_creator.ipynb","timestamp":1776178739426},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/lora_vertical_slice_dataset_creator.ipynb","timestamp":1776027716448},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/lora_vertical_slice_dataset_creator.ipynb","timestamp":1773663661932},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773663290922},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773264797996},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773163850245},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773090196076},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773089575687},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/civit_caption_prepper.ipynb","timestamp":1773080355474},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/Drive to WebP.ipynb","timestamp":1772998638620},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/Drive to WebP.ipynb","timestamp":1763646205520},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/Drive to WebP.ipynb","timestamp":1760993725927},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1760450712160},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1756712618300},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1747490904984},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1740037333374},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1736477078136},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1725365086834}],"collapsed_sections":["ljPFdGvYyD-6","Cs5ftnHQyapT","dTwnU7KYzY2J","s7R3l3-pY5W7","4PjK9a8Sni3A","kVAe29swHo4I"]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}