|
|
|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
"cells": [
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 1,
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -26,18 +26,11 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"# Configuration\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Global settings for:\n",
|
|
|
|
|
"- Data paths and image parameters\n",
|
|
|
|
|
"- Training hyperparameters\n",
|
|
|
|
|
"- Model architecture options\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "# Configuration\n\nGlobal settings for:\n- Data paths and image parameters\n- Training hyperparameters\n- Model architecture options\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 2,
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -101,23 +94,11 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Dataset\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Google/Yandex image pair loader with homography augmentation.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Features:**\n",
|
|
|
|
|
"- Loads paired images from dual camera sources\n",
|
|
|
|
|
"- Applies random homography transformations\n",
|
|
|
|
|
"- Supports configurable train/val split\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Returns:**\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "## Dataset\n\nGoogle/Yandex image pair loader with homography augmentation.\n\n**Features:**\n- Loads paired images from dual camera sources\n- Applies random homography transformations\n- Supports configurable train/val split\n\n**Returns:**\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 15,
|
|
|
|
|
"id": "8740e758",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -230,7 +211,7 @@
|
|
|
|
|
" image_size=(256, 256), augment_train=True, cache_level=5):\n",
|
|
|
|
|
" transform = transforms.Compose([\n",
|
|
|
|
|
" transforms.ToTensor(),\n",
|
|
|
|
|
" transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),\n",
|
|
|
|
|
" # transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),\n",
|
|
|
|
|
" ])\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" full_ds = YaGoDataset(root_dir, transform=transform, augment=False, image_size=image_size, cache_level=cache_level)\n",
|
|
|
|
|
@@ -260,24 +241,11 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Model\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"`HomographyCNN6` — CNN architecture for homography estimation.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Output:** 6 parameters\n",
|
|
|
|
|
"- `rx, ry, rz` — rotation angles (radians)\n",
|
|
|
|
|
"- `tx, ty` — translation offsets\n",
|
|
|
|
|
"- `scale` — isotropic scale factor\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Architecture:**\n",
|
|
|
|
|
"- Dual-branch CNN (Google + Yandex images)\n",
|
|
|
|
|
"- Shared backbone (configurable: resnet18/34/50)\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "## Model\n\n`HomographyCNN6` — CNN architecture for homography estimation.\n\n**Output:** 6 parameters\n- `rx, ry, rz` — rotation angles (radians)\n- `tx, ty` — translation offsets\n- `scale` — isotropic scale factor\n\n**Architecture:**\n- Dual-branch CNN (Google + Yandex images)\n- Shared backbone (configurable: resnet18/34/50)\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 4,
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -298,7 +266,7 @@
|
|
|
|
|
" nn.Linear(512, 256),\n",
|
|
|
|
|
" nn.ReLU(inplace=True),\n",
|
|
|
|
|
" nn.Dropout(dropout_rate),\n",
|
|
|
|
|
" nn.Linear(256, 6),\n",
|
|
|
|
|
" nn.Linear(256, 9),\n",
|
|
|
|
|
" )\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" def forward(self, img1, img2):\n",
|
|
|
|
|
@@ -307,14 +275,95 @@
|
|
|
|
|
" combined = torch.cat([f1, f2, torch.abs(f1 - f2), f1 * f2], dim=1)\n",
|
|
|
|
|
" return self.head(combined)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" def decode_output(self, output):\n",
|
|
|
|
|
" tx, ty = output[:, 0], output[:, 1]\n",
|
|
|
|
|
" sin1, cos1 = torch.tanh(output[:, 2]), torch.tanh(output[:, 3])\n",
|
|
|
|
|
" sin2, cos2 = torch.tanh(output[:, 4]), torch.tanh(output[:, 5])\n",
|
|
|
|
|
" sin3, cos3 = torch.tanh(output[:, 6]), torch.tanh(output[:, 7])\n",
|
|
|
|
|
" scale = output[:, 8]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" angle1 = torch.atan2(sin1, cos1)\n",
|
|
|
|
|
" angle2 = torch.atan2(sin2, cos2)\n",
|
|
|
|
|
" angle3 = torch.atan2(sin3, cos3)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" return torch.stack([tx, ty, angle1, angle2, angle3, scale], dim=1)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"class HomographyLoss6(nn.Module):\n",
|
|
|
|
|
" def __init__(self):\n",
|
|
|
|
|
" def __init__(self, angle_loss_weight=1.0, trans_loss_weight=1.0, scale_loss_weight=1.0):\n",
|
|
|
|
|
" super().__init__()\n",
|
|
|
|
|
" self.criterion = nn.MSELoss()\n",
|
|
|
|
|
" self.angle_loss_weight = angle_loss_weight\n",
|
|
|
|
|
" self.trans_loss_weight = trans_loss_weight\n",
|
|
|
|
|
" self.scale_loss_weight = scale_loss_weight\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" def forward(self, pred, target):\n",
|
|
|
|
|
" return self.criterion(pred, target)\n",
|
|
|
|
|
" tx_loss = self.criterion(pred[:, 0], target[:, 0])\n",
|
|
|
|
|
" ty_loss = self.criterion(pred[:, 1], target[:, 1])\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" sin1_pred, cos1_pred = pred[:, 2], pred[:, 3]\n",
|
|
|
|
|
" sin2_pred, cos2_pred = pred[:, 4], pred[:, 5]\n",
|
|
|
|
|
" sin3_pred, cos3_pred = pred[:, 6], pred[:, 7]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" sin1_target = torch.sin(target[:, 2])\n",
|
|
|
|
|
" cos1_target = torch.cos(target[:, 2])\n",
|
|
|
|
|
" sin2_target = torch.sin(target[:, 3])\n",
|
|
|
|
|
" cos2_target = torch.cos(target[:, 3])\n",
|
|
|
|
|
" sin3_target = torch.sin(target[:, 4])\n",
|
|
|
|
|
" cos3_target = torch.cos(target[:, 4])\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" sin1_pred_t = torch.tanh(sin1_pred)\n",
|
|
|
|
|
" cos1_pred_t = torch.tanh(cos1_pred)\n",
|
|
|
|
|
" sin2_pred_t = torch.tanh(sin2_pred)\n",
|
|
|
|
|
" cos2_pred_t = torch.tanh(cos2_pred)\n",
|
|
|
|
|
" sin3_pred_t = torch.tanh(sin3_pred)\n",
|
|
|
|
|
" cos3_pred_t = torch.tanh(cos3_pred)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" angle1_loss = (1 - (sin1_pred_t * sin1_target + cos1_pred_t * cos1_target)).mean()\n",
|
|
|
|
|
" angle2_loss = (1 - (sin2_pred_t * sin2_target + cos2_pred_t * cos2_target)).mean()\n",
|
|
|
|
|
" angle3_loss = (1 - (sin3_pred_t * sin3_target + cos3_pred_t * cos3_target)).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" scale_loss = self.criterion(pred[:, 8], target[:, 5])\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" total_loss = (\n",
|
|
|
|
|
" self.trans_loss_weight * (tx_loss + ty_loss) +\n",
|
|
|
|
|
" self.angle_loss_weight * (angle1_loss + angle2_loss + angle3_loss) +\n",
|
|
|
|
|
" self.scale_loss_weight * scale_loss\n",
|
|
|
|
|
" )\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" return total_loss\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" def compute_mse_components(self, pred, target):\n",
|
|
|
|
|
" tx_mse = self.criterion(pred[:, 0], target[:, 0]).item()\n",
|
|
|
|
|
" ty_mse = self.criterion(pred[:, 1], target[:, 1]).item()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" sin1_target = torch.sin(target[:, 2])\n",
|
|
|
|
|
" cos1_target = torch.cos(target[:, 2])\n",
|
|
|
|
|
" sin2_target = torch.sin(target[:, 3])\n",
|
|
|
|
|
" cos2_target = torch.cos(target[:, 3])\n",
|
|
|
|
|
" sin3_target = torch.sin(target[:, 4])\n",
|
|
|
|
|
" cos3_target = torch.cos(target[:, 4])\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" sin1_pred_t = torch.tanh(pred[:, 2])\n",
|
|
|
|
|
" cos1_pred_t = torch.tanh(pred[:, 3])\n",
|
|
|
|
|
" sin2_pred_t = torch.tanh(pred[:, 4])\n",
|
|
|
|
|
" cos2_pred_t = torch.tanh(pred[:, 5])\n",
|
|
|
|
|
" sin3_pred_t = torch.tanh(pred[:, 6])\n",
|
|
|
|
|
" cos3_pred_t = torch.tanh(pred[:, 7])\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" angle1_loss = (1 - (sin1_pred_t * sin1_target + cos1_pred_t * cos1_target)).mean().item()\n",
|
|
|
|
|
" angle2_loss = (1 - (sin2_pred_t * sin2_target + cos2_pred_t * cos2_target)).mean().item()\n",
|
|
|
|
|
" angle3_loss = (1 - (sin3_pred_t * sin3_target + cos3_pred_t * cos3_target)).mean().item()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" scale_mse = self.criterion(pred[:, 8], target[:, 5]).item()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" avg_angle_loss = (angle1_loss + angle2_loss + angle3_loss) / 3\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" return {\n",
|
|
|
|
|
" 'trans': (tx_mse + ty_mse) / 2,\n",
|
|
|
|
|
" 'angle': avg_angle_loss,\n",
|
|
|
|
|
" 'scale': scale_mse\n",
|
|
|
|
|
" }\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def count_parameters(model):\n",
|
|
|
|
|
@@ -325,25 +374,11 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Training\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"`HomographyTrainer` — training loop with validation and checkpointing.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Features:**\n",
|
|
|
|
|
"- Epoch-based training with tqdm progress bar\n",
|
|
|
|
|
"- Adam optimizer with configurable LR\n",
|
|
|
|
|
"- Validation after each epoch\n",
|
|
|
|
|
"- Best model auto-save\n",
|
|
|
|
|
"- Periodic checkpoints (every N epochs via `save_every_n_epochs`)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Checkpoint saving:**\n",
|
|
|
|
|
"- `best_model.pt` — lowest validation loss\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "## Training\n\n`HomographyTrainer` — training loop with validation and checkpointing.\n\n**Features:**\n- Epoch-based training with tqdm progress bar\n- Adam optimizer with configurable LR\n- Validation after each epoch\n- Best model auto-save\n- Periodic checkpoints (every N epochs via `save_every_n_epochs`)\n\n**Checkpoint saving:**\n- `best_model.pt` — lowest validation loss\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 5,
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -389,9 +424,10 @@
|
|
|
|
|
" total_loss += loss.item() * google_img.size(0)\n",
|
|
|
|
|
" total_samples += google_img.size(0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" mse_trans_sum += torch.mean((output[:, 3:5] - target[:, 3:5]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_angle_sum += torch.mean((output[:, 0:3] - target[:, 0:3]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_scale_sum += torch.mean((output[:, 5:6] - target[:, 5:6]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_components = self.criterion.compute_mse_components(output, target)\n",
|
|
|
|
|
" mse_trans_sum += mse_components['trans'] * google_img.size(0)\n",
|
|
|
|
|
" mse_angle_sum += mse_components['angle'] * google_img.size(0)\n",
|
|
|
|
|
" mse_scale_sum += mse_components['scale'] * google_img.size(0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" pbar.set_postfix({\"loss\": loss.item()})\n",
|
|
|
|
|
"\n",
|
|
|
|
|
@@ -415,9 +451,10 @@
|
|
|
|
|
" total_loss += loss.item() * google_img.size(0)\n",
|
|
|
|
|
" total_samples += google_img.size(0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" mse_trans_sum += torch.mean((output[:, 3:5] - target[:, 3:5]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_angle_sum += torch.mean((output[:, 0:3] - target[:, 0:3]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_scale_sum += torch.mean((output[:, 5:6] - target[:, 5:6]) ** 2).item() * google_img.size(0)\n",
|
|
|
|
|
" mse_components = self.criterion.compute_mse_components(output, target)\n",
|
|
|
|
|
" mse_trans_sum += mse_components['trans'] * google_img.size(0)\n",
|
|
|
|
|
" mse_angle_sum += mse_components['angle'] * google_img.size(0)\n",
|
|
|
|
|
" mse_scale_sum += mse_components['scale'] * google_img.size(0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" self.val_mse_trans.append(mse_trans_sum / total_samples)\n",
|
|
|
|
|
" self.val_mse_angle.append(mse_angle_sum / total_samples)\n",
|
|
|
|
|
@@ -462,18 +499,11 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Analysis\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Visualization and evaluation tools:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"- Training metrics plots (loss curves)\n",
|
|
|
|
|
"- Prediction visualization on sample images\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "## Analysis\n\nVisualization and evaluation tools:\n\n- Training metrics plots (loss curves)\n- Prediction visualization on sample images\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 6,
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
@@ -483,6 +513,12 @@
|
|
|
|
|
"os.makedirs(IMG_DIR, exist_ok=True)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def angular_difference(pred_angles, target_angles):\n",
|
|
|
|
|
" diff = pred_angles - target_angles\n",
|
|
|
|
|
" diff = torch.atan2(torch.sin(diff), torch.cos(diff))\n",
|
|
|
|
|
" return torch.abs(diff)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def analyze_training(trainer):\n",
|
|
|
|
|
" print(\"=== Training Analysis ===\\n\")\n",
|
|
|
|
|
"\n",
|
|
|
|
|
@@ -500,7 +536,7 @@
|
|
|
|
|
" trainer.model.eval()\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" n_samples = 50\n",
|
|
|
|
|
" names = [\"rx\", \"ry\", \"rz\", \"tx\", \"ty\", \"scale\"]\n",
|
|
|
|
|
" names = [\"tx\", \"ty\", \"rx\", \"ry\", \"rz\", \"scale\"]\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" with torch.no_grad():\n",
|
|
|
|
|
" all_errors = [[] for _ in range(6)]\n",
|
|
|
|
|
@@ -516,11 +552,23 @@
|
|
|
|
|
" yandex_img = batch[\"yandex_img\"].to(trainer.device)\n",
|
|
|
|
|
" target_params = batch[\"homography_params\"].to(trainer.device)\n",
|
|
|
|
|
" pred_params = trainer.model(google_img, yandex_img)\n",
|
|
|
|
|
" decoded_pred = trainer.model.decode_output(pred_params)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" tx_error = torch.abs(decoded_pred[:, 0] - target_params[:, 0]).item()\n",
|
|
|
|
|
" ty_error = torch.abs(decoded_pred[:, 1] - target_params[:, 1]).item()\n",
|
|
|
|
|
" rx_error = angular_difference(decoded_pred[:, 2], target_params[:, 2]).item()\n",
|
|
|
|
|
" ry_error = angular_difference(decoded_pred[:, 3], target_params[:, 3]).item()\n",
|
|
|
|
|
" rz_error = angular_difference(decoded_pred[:, 4], target_params[:, 4]).item()\n",
|
|
|
|
|
" scale_error = torch.abs(decoded_pred[:, 5] - target_params[:, 5]).item()\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" errors = [tx_error, ty_error, rx_error, ry_error, rz_error, scale_error]\n",
|
|
|
|
|
" targets = target_params[0].cpu().numpy()\n",
|
|
|
|
|
" preds = decoded_pred[0].cpu().numpy()\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" for j in range(6):\n",
|
|
|
|
|
" all_errors[j].append(torch.abs(pred_params[0, j] - target_params[0, j]).item())\n",
|
|
|
|
|
" all_targets[j].append(target_params[0, j].item())\n",
|
|
|
|
|
" all_preds[j].append(pred_params[0, j].item())\n",
|
|
|
|
|
" all_errors[j].append(errors[j])\n",
|
|
|
|
|
" all_targets[j].append(targets[j])\n",
|
|
|
|
|
" all_preds[j].append(preds[j])\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" mean_errors = [np.mean(all_errors[i]) for i in range(6)]\n",
|
|
|
|
|
" std_errors = [np.std(all_errors[i]) for i in range(6)]\n",
|
|
|
|
|
@@ -618,10 +666,18 @@
|
|
|
|
|
" yandex_img = batch[\"yandex_img\"].to(trainer.device)\n",
|
|
|
|
|
" target_params = batch[\"homography_params\"].to(trainer.device)\n",
|
|
|
|
|
" pred_params = trainer.model(google_img, yandex_img)\n",
|
|
|
|
|
" decoded_pred = trainer.model.decode_output(pred_params)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" errors = torch.abs(pred_params[0] - target_params[0]).cpu().numpy()\n",
|
|
|
|
|
" tx_error = torch.abs(decoded_pred[:, 0] - target_params[:, 0]).cpu().numpy()\n",
|
|
|
|
|
" ty_error = torch.abs(decoded_pred[:, 1] - target_params[:, 1]).cpu().numpy()\n",
|
|
|
|
|
" rx_error = angular_difference(decoded_pred[:, 2], target_params[:, 2]).cpu().numpy()\n",
|
|
|
|
|
" ry_error = angular_difference(decoded_pred[:, 3], target_params[:, 3]).cpu().numpy()\n",
|
|
|
|
|
" rz_error = angular_difference(decoded_pred[:, 4], target_params[:, 4]).cpu().numpy()\n",
|
|
|
|
|
" scale_error = torch.abs(decoded_pred[:, 5] - target_params[:, 5]).cpu().numpy()\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" errors = np.array([tx_error[0], ty_error[0], rx_error[0], ry_error[0], rz_error[0], scale_error[0]])\n",
|
|
|
|
|
" targets = target_params[0].cpu().numpy()\n",
|
|
|
|
|
" preds = pred_params[0].cpu().numpy()\n",
|
|
|
|
|
" preds = decoded_pred[0].cpu().numpy()\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" fig, axes = plt.subplots(2, 2, figsize=(12, 10))\n",
|
|
|
|
|
" \n",
|
|
|
|
|
@@ -683,91 +739,13 @@
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Main Pipeline\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Executes the full training workflow:\n",
|
|
|
|
|
"1. Load dataset info\n",
|
|
|
|
|
"2. Create data loaders\n",
|
|
|
|
|
"3. Initialize model\n",
|
|
|
|
|
"4. Train with validation\n",
|
|
|
|
|
"5. Analyze and export results\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"**Outputs:**\n",
|
|
|
|
|
"- Model checkpoints in `runs/checkpoints/`\n",
|
|
|
|
|
"- TensorBoard logs in `runs/`\n"
|
|
|
|
|
]
|
|
|
|
|
"source": "## Main Pipeline\n\nExecutes the full training workflow:\n1. Load dataset info\n2. Create data loaders\n3. Initialize model\n4. Train with validation\n5. Analyze and export results\n\n**Outputs:**\n- Model checkpoints in `runs/checkpoints/`\n- TensorBoard logs in `runs/`\n"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stderr",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"2026-04-05 12:35:20,728 - ==================================================\n",
|
|
|
|
|
"2026-04-05 12:35:20,730 - SiaN Training Pipeline\n",
|
|
|
|
|
"2026-04-05 12:35:20,731 - ==================================================\n",
|
|
|
|
|
"2026-04-05 12:35:32,423 - Dataset: 327 samples, keys=['google_img', 'yandex_img', 'homography_matrix', 'homography_params']\n",
|
|
|
|
|
"2026-04-05 12:35:54,074 - Data loaders created: train=261, val=66\n",
|
|
|
|
|
"2026-04-05 12:35:54,366 - Model created with 12,358,470 parameters\n",
|
|
|
|
|
"2026-04-05 12:35:54,368 - Using device: cpu\n",
|
|
|
|
|
"2026-04-05 12:35:54,374 - Starting training...\n",
|
|
|
|
|
"Epoch 1: 0%| | 0/9 [00:00<?, ?it/s]c:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\utils\\data\\dataloader.py:775: UserWarning: 'pin_memory' argument is set as true but no accelerator is found, then device pinned memory won't be used.\n",
|
|
|
|
|
" super().__init__(loader)\n",
|
|
|
|
|
"Epoch 1: 100%|██████████| 9/9 [00:35<00:00, 3.98s/it, loss=0.795]\n",
|
|
|
|
|
"Validation: 100%|██████████| 3/3 [00:03<00:00, 1.13s/it]\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"Train Loss: 0.6337, Val Loss: 0.6173\n",
|
|
|
|
|
" MSE - Trans: 0.0323, Angle: 1.2063, Scale: 0.0204\n",
|
|
|
|
|
"Best model saved (val loss: 0.6173)\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "stderr",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"Epoch 2: 44%|████▍ | 4/9 [00:18<00:22, 4.52s/it, loss=0.631]\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"ename": "KeyboardInterrupt",
|
|
|
|
|
"evalue": "",
|
|
|
|
|
"output_type": "error",
|
|
|
|
|
"traceback": [
|
|
|
|
|
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
|
|
|
|
"\u001b[31mKeyboardInterrupt\u001b[39m Traceback (most recent call last)",
|
|
|
|
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 33\u001b[39m\n\u001b[32m 31\u001b[39m trainer = HomographyTrainer(model, train_loader, val_loader, device)\n\u001b[32m 32\u001b[39m logger.info(\u001b[33m\"\u001b[39m\u001b[33mStarting training...\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m---> \u001b[39m\u001b[32m33\u001b[39m \u001b[43mtrainer\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtrain\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mepochs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 34\u001b[39m logger.info(\u001b[33m\"\u001b[39m\u001b[33mTraining completed\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 36\u001b[39m logger.info(\u001b[33m\"\u001b[39m\u001b[33mAnalyzing model...\u001b[39m\u001b[33m\"\u001b[39m)\n",
|
|
|
|
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 81\u001b[39m, in \u001b[36mHomographyTrainer.train\u001b[39m\u001b[34m(self, num_epochs)\u001b[39m\n\u001b[32m 78\u001b[39m \u001b[38;5;28mself\u001b[39m.writer = SummaryWriter(log_dir)\n\u001b[32m 80\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m epoch \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[32m1\u001b[39m, num_epochs + \u001b[32m1\u001b[39m):\n\u001b[32m---> \u001b[39m\u001b[32m81\u001b[39m train_metrics = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mtrain_epoch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mepoch\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 82\u001b[39m val_metrics = \u001b[38;5;28mself\u001b[39m.validate()\n\u001b[32m 83\u001b[39m \u001b[38;5;28mself\u001b[39m.train_losses.append(train_metrics[\u001b[33m\"\u001b[39m\u001b[33mloss\u001b[39m\u001b[33m\"\u001b[39m])\n",
|
|
|
|
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 31\u001b[39m, in \u001b[36mHomographyTrainer.train_epoch\u001b[39m\u001b[34m(self, epoch)\u001b[39m\n\u001b[32m 28\u001b[39m target = batch[\u001b[33m\"\u001b[39m\u001b[33mhomography_params\u001b[39m\u001b[33m\"\u001b[39m].to(\u001b[38;5;28mself\u001b[39m.device)\n\u001b[32m 30\u001b[39m \u001b[38;5;28mself\u001b[39m.optimizer.zero_grad()\n\u001b[32m---> \u001b[39m\u001b[32m31\u001b[39m output = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mgoogle_img\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myandex_img\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 32\u001b[39m loss = \u001b[38;5;28mself\u001b[39m.criterion(output, target)\n\u001b[32m 33\u001b[39m loss.backward()\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1776\u001b[39m, in \u001b[36mModule._wrapped_call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._compiled_call_impl(*args, **kwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[32m 1775\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1776\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1787\u001b[39m, in \u001b[36mModule._call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1782\u001b[39m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[32m 1783\u001b[39m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[32m 1784\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_pre_hooks\n\u001b[32m 1785\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[32m 1786\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[32m-> \u001b[39m\u001b[32m1787\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1789\u001b[39m result = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1790\u001b[39m called_always_called_hooks = \u001b[38;5;28mset\u001b[39m()\n",
|
|
|
|
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 20\u001b[39m, in \u001b[36mHomographyCNN6.forward\u001b[39m\u001b[34m(self, img1, img2)\u001b[39m\n\u001b[32m 19\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, img1, img2):\n\u001b[32m---> \u001b[39m\u001b[32m20\u001b[39m f1 = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mbackbone\u001b[49m\u001b[43m(\u001b[49m\u001b[43mimg1\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 21\u001b[39m f2 = \u001b[38;5;28mself\u001b[39m.backbone(img2)\n\u001b[32m 22\u001b[39m combined = torch.cat([f1, f2, torch.abs(f1 - f2), f1 * f2], dim=\u001b[32m1\u001b[39m)\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1776\u001b[39m, in \u001b[36mModule._wrapped_call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._compiled_call_impl(*args, **kwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[32m 1775\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1776\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1787\u001b[39m, in \u001b[36mModule._call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1782\u001b[39m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[32m 1783\u001b[39m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[32m 1784\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_pre_hooks\n\u001b[32m 1785\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[32m 1786\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[32m-> \u001b[39m\u001b[32m1787\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1789\u001b[39m result = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1790\u001b[39m called_always_called_hooks = \u001b[38;5;28mset\u001b[39m()\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torchvision\\models\\resnet.py:285\u001b[39m, in \u001b[36mResNet.forward\u001b[39m\u001b[34m(self, x)\u001b[39m\n\u001b[32m 284\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, x: Tensor) -> Tensor:\n\u001b[32m--> \u001b[39m\u001b[32m285\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_forward_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torchvision\\models\\resnet.py:274\u001b[39m, in \u001b[36mResNet._forward_impl\u001b[39m\u001b[34m(self, x)\u001b[39m\n\u001b[32m 271\u001b[39m x = \u001b[38;5;28mself\u001b[39m.maxpool(x)\n\u001b[32m 273\u001b[39m x = \u001b[38;5;28mself\u001b[39m.layer1(x)\n\u001b[32m--> \u001b[39m\u001b[32m274\u001b[39m x = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mlayer2\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 275\u001b[39m x = \u001b[38;5;28mself\u001b[39m.layer3(x)\n\u001b[32m 276\u001b[39m x = \u001b[38;5;28mself\u001b[39m.layer4(x)\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1776\u001b[39m, in \u001b[36mModule._wrapped_call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._compiled_call_impl(*args, **kwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[32m 1775\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1776\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1787\u001b[39m, in \u001b[36mModule._call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1782\u001b[39m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[32m 1783\u001b[39m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[32m 1784\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_pre_hooks\n\u001b[32m 1785\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[32m 1786\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[32m-> \u001b[39m\u001b[32m1787\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1789\u001b[39m result = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1790\u001b[39m called_always_called_hooks = \u001b[38;5;28mset\u001b[39m()\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\container.py:253\u001b[39m, in \u001b[36mSequential.forward\u001b[39m\u001b[34m(self, input)\u001b[39m\n\u001b[32m 249\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 250\u001b[39m \u001b[33;03mRuns the forward pass.\u001b[39;00m\n\u001b[32m 251\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 252\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m module \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m:\n\u001b[32m--> \u001b[39m\u001b[32m253\u001b[39m \u001b[38;5;28minput\u001b[39m = \u001b[43mmodule\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 254\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28minput\u001b[39m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1776\u001b[39m, in \u001b[36mModule._wrapped_call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._compiled_call_impl(*args, **kwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[32m 1775\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1776\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1787\u001b[39m, in \u001b[36mModule._call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1782\u001b[39m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[32m 1783\u001b[39m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[32m 1784\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_pre_hooks\n\u001b[32m 1785\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[32m 1786\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[32m-> \u001b[39m\u001b[32m1787\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1789\u001b[39m result = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1790\u001b[39m called_always_called_hooks = \u001b[38;5;28mset\u001b[39m()\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torchvision\\models\\resnet.py:96\u001b[39m, in \u001b[36mBasicBlock.forward\u001b[39m\u001b[34m(self, x)\u001b[39m\n\u001b[32m 93\u001b[39m out = \u001b[38;5;28mself\u001b[39m.bn1(out)\n\u001b[32m 94\u001b[39m out = \u001b[38;5;28mself\u001b[39m.relu(out)\n\u001b[32m---> \u001b[39m\u001b[32m96\u001b[39m out = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mconv2\u001b[49m\u001b[43m(\u001b[49m\u001b[43mout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 97\u001b[39m out = \u001b[38;5;28mself\u001b[39m.bn2(out)\n\u001b[32m 99\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.downsample \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1776\u001b[39m, in \u001b[36mModule._wrapped_call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1774\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._compiled_call_impl(*args, **kwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[32m 1775\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1776\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1787\u001b[39m, in \u001b[36mModule._call_impl\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 1782\u001b[39m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[32m 1783\u001b[39m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[32m 1784\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m._forward_pre_hooks\n\u001b[32m 1785\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[32m 1786\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[32m-> \u001b[39m\u001b[32m1787\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1789\u001b[39m result = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1790\u001b[39m called_always_called_hooks = \u001b[38;5;28mset\u001b[39m()\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\conv.py:553\u001b[39m, in \u001b[36mConv2d.forward\u001b[39m\u001b[34m(self, input)\u001b[39m\n\u001b[32m 552\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m: Tensor) -> Tensor:\n\u001b[32m--> \u001b[39m\u001b[32m553\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_conv_forward\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mbias\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\admin\\Projects\\autopilot\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\conv.py:548\u001b[39m, in \u001b[36mConv2d._conv_forward\u001b[39m\u001b[34m(self, input, weight, bias)\u001b[39m\n\u001b[32m 535\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.padding_mode != \u001b[33m\"\u001b[39m\u001b[33mzeros\u001b[39m\u001b[33m\"\u001b[39m:\n\u001b[32m 536\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m F.conv2d(\n\u001b[32m 537\u001b[39m F.pad(\n\u001b[32m 538\u001b[39m \u001b[38;5;28minput\u001b[39m, \u001b[38;5;28mself\u001b[39m._reversed_padding_repeated_twice, mode=\u001b[38;5;28mself\u001b[39m.padding_mode\n\u001b[32m (...)\u001b[39m\u001b[32m 545\u001b[39m \u001b[38;5;28mself\u001b[39m.groups,\n\u001b[32m 546\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m548\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mF\u001b[49m\u001b[43m.\u001b[49m\u001b[43mconv2d\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 549\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbias\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstride\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mpadding\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mdilation\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mgroups\u001b[49m\n\u001b[32m 550\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
|
|
|
"\u001b[31mKeyboardInterrupt\u001b[39m: "
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
@@ -836,15 +814,7 @@
|
|
|
|
|
"name": "python3"
|
|
|
|
|
},
|
|
|
|
|
"language_info": {
|
|
|
|
|
"codemirror_mode": {
|
|
|
|
|
"name": "ipython",
|
|
|
|
|
"version": 3
|
|
|
|
|
},
|
|
|
|
|
"file_extension": ".py",
|
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
|
"version": "3.11.0"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|