{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":16880,"databundleVersionId":858837},{"sourceType":"competition","sourceId":19989,"databundleVersionId":1160143},{"sourceType":"datasetVersion","sourceId":854304,"datasetId":452468,"databundleVersionId":880773}],"dockerImageVersionId":31328,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\n\nimport cv2\nimport albumentations as A\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nimport torchvision.models as models\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nfrom IPython.display import HTML\nfrom base64 import b64encode\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:46:54.796108Z","iopub.execute_input":"2026-05-13T10:46:54.796485Z","iopub.status.idle":"2026-05-13T10:47:05.292468Z","shell.execute_reply.started":"2026-05-13T10:46:54.796455Z","shell.execute_reply":"2026-05-13T10:47:05.291143Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install timm omegaconf pycocotools effdet\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:05.294783Z","iopub.execute_input":"2026-05-13T10:47:05.295537Z","iopub.status.idle":"2026-05-13T10:47:11.655840Z","shell.execute_reply.started":"2026-05-13T10:47:05.295474Z","shell.execute_reply":"2026-05-13T10:47:11.654275Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from effdet import get_efficientdet_config, EfficientDet\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:11.657792Z","iopub.execute_input":"2026-05-13T10:47:11.658629Z","iopub.status.idle":"2026-05-13T10:47:17.791900Z","shell.execute_reply.started":"2026-05-13T10:47:11.658563Z","shell.execute_reply":"2026-05-13T10:47:17.790185Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"p = '/kaggle/input/competitions/global-wheat-detection/'\ndf = pd.read_csv(p+'train.csv')\n\ndf.head()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:17.794989Z","iopub.execute_input":"2026-05-13T10:47:17.795762Z","iopub.status.idle":"2026-05-13T10:47:18.107888Z","shell.execute_reply.started":"2026-05-13T10:47:17.795723Z","shell.execute_reply":"2026-05-13T10:47:18.106591Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"bbox = np.stack(df['bbox'].apply(lambda x: np.fromstring(x[1:-1], sep=',')))\nfor i, column in enumerate(['x', 'y', 'w', 'h']):\n    df[column] = bbox[:,i]\n\ndf.drop('bbox', \n        axis=1, \n        inplace=True)\n\ndf.head()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:18.109294Z","iopub.execute_input":"2026-05-13T10:47:18.110673Z","iopub.status.idle":"2026-05-13T10:47:18.699194Z","shell.execute_reply.started":"2026-05-13T10:47:18.110633Z","shell.execute_reply":"2026-05-13T10:47:18.698049Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"uni = df[['image_id', 'source']].copy()\nuni.drop_duplicates(inplace=True)\n\nuni['fi'] = 1\nuni['fi'] = uni.groupby('source')['fi'].transform('cumsum')\n\nuni = uni[uni['fi'] <= 4].copy()\nuni.reset_index(drop=True, \n                inplace=True)\n\nuni.head()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:18.700536Z","iopub.execute_input":"2026-05-13T10:47:18.700923Z","iopub.status.idle":"2026-05-13T10:47:18.749995Z","shell.execute_reply.started":"2026-05-13T10:47:18.700884Z","shell.execute_reply":"2026-05-13T10:47:18.748405Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def transforms():\n    \n    return A.Compose(\n        [\n            A.RandomSizedCrop(\n                min_max_height=(800, 800), \n                size=(1024, 1024),\n                p=.5\n            ), \n            A.HorizontalFlip(p=.5), \n            A.VerticalFlip(p=.5), \n\n            A.CoarseDropout(\n                num_holes_range=(1, 8), \n                hole_height_range=(32, 64), \n                hole_width_range=(32, 64),\n                p=.5\n            ), \n            \n            A.Resize(height=512, width=512, p=1)\n        ], \n        p=1, \n        bbox_params=A.BboxParams(\n            format='pascal_voc',\n            min_area=0, \n            min_visibility=0,\n            label_fields=['labels']\n        )\n    )\n\ndef visualization(uni, df, transforms):\n    \n    fig, axes = plt.subplots(int(uni.shape[0] // 4), 4, figsize=(20, 40))\n    \n    for ax, n in zip(axes.flatten(), uni['image_id'].unique()):\n        \n        image = cv2.imread(p+f'train/{n}.jpg', cv2.IMREAD_COLOR)\n        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32) / 255\n        \n        bboxes = df[df['image_id'] == n][['x', 'y', 'w', 'h']].values\n        bboxes[:, 2] = bboxes[:, 0] + bboxes[:, 2]\n        bboxes[:, 3] = bboxes[:, 1] + bboxes[:, 3]\n\n        labels = np.ones((bboxes.shape[0],))\n\n        if transforms:\n            f = transforms()  \n            r = f(**{\n                'image': image,\n                'bboxes': bboxes,\n                'labels': labels\n            })\n            image = r['image']\n            bboxes = r['bboxes']\n            labels = r['labels']\n        \n        ax.imshow(image)\n        \n        for box in bboxes:\n            x1, y1, x2, y2 = box.astype(int)\n            r = plt.Rectangle((x1, y1), x2-x1, y2-y1, \n                              linewidth=2, \n                              edgecolor='red', \n                              facecolor='none')\n            ax.add_patch(r)\n        \n        ax.axis('off')\n    \n    plt.tight_layout()\n    plt.show()\n\nvisualization(uni, df, None)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:18.751309Z","iopub.execute_input":"2026-05-13T10:47:18.752339Z","iopub.status.idle":"2026-05-13T10:47:29.394956Z","shell.execute_reply.started":"2026-05-13T10:47:18.752269Z","shell.execute_reply":"2026-05-13T10:47:29.393752Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"visualization(uni, df, transforms)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:29.396310Z","iopub.execute_input":"2026-05-13T10:47:29.397043Z","iopub.status.idle":"2026-05-13T10:47:37.892593Z","shell.execute_reply.started":"2026-05-13T10:47:29.397007Z","shell.execute_reply":"2026-05-13T10:47:37.890516Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\"\"\"\n\nimage \n    │\n    ▼\n┌────────┐\n│ C1     │\n│        │   \n└───┬────┘                                    \n    │ \n    │ down\n    ▼\n┌────────┐\n│ C2     │ \n│        │ \n└───┬────┘\n    │ \n    │ down\n    ▼\n┌────────┐\n│ C3     │─────► P3 (64×64) ─────► conv ─────► box      \n│        │        ▲         ─────► conv ─────► class  \n└───┬────┘        │ up\n    │ down        │\n    ▼             │\n┌────────┐        │\n│ C4     │─────► P4 (32×32) ─────► conv ─────► box      \n│        │        ▲         ─────► conv ─────► class  \n└───┬────┘        │ up\n    │ down        │\n    ▼             │\n┌────────┐        │\n│ C5     │─────► P5 (16×16) ─────► conv ─────► box      \n│        │        │         ─────► conv ─────► class  \n└────────┘        │ down\n                  ▼\n                 P6 (8×8)   ─────► conv ─────► box      \n                  │         ─────► conv ─────► class  \n                  │ down\n                  ▼\n                 P7 (4×4)   ─────► conv ─────► box      \n                            ─────► conv ─────► class  \n \n BACKBONE        FPN               BOX NET                          \n Bottom-Up       Top-Down          CLASS NET\n\n\n BiFPN = (Top-down + Bottom-up) * N \n\n\n\"\"\"\n\nconfig = get_efficientdet_config('tf_efficientdet_d5')\nconfig.image_size = [512, 512]\nconfig.num_classes = 1\n\nmodel = EfficientDet(config, pretrained_backbone=False)\n\nfor n, m in model.named_children():\n    s = sum(p.numel() for p in m.parameters())\n    print (n, s)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:37.895710Z","iopub.execute_input":"2026-05-13T10:47:37.896581Z","iopub.status.idle":"2026-05-13T10:47:38.613548Z","shell.execute_reply.started":"2026-05-13T10:47:37.896490Z","shell.execute_reply":"2026-05-13T10:47:38.612114Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"batch = torch.randn(2, 3, 512, 512)\nbackbone_out = model.backbone(batch)\n\nfor i in range(len(backbone_out)):\n    print (backbone_out[i].shape)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:38.616690Z","iopub.execute_input":"2026-05-13T10:47:38.616998Z","iopub.status.idle":"2026-05-13T10:47:43.411016Z","shell.execute_reply.started":"2026-05-13T10:47:38.616963Z","shell.execute_reply":"2026-05-13T10:47:43.409629Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fpn_out = model.fpn(backbone_out)\n\nfor i in range(len(fpn_out)):\n    print (fpn_out[i].shape)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:43.412446Z","iopub.execute_input":"2026-05-13T10:47:43.413010Z","iopub.status.idle":"2026-05-13T10:47:45.307137Z","shell.execute_reply.started":"2026-05-13T10:47:43.412973Z","shell.execute_reply":"2026-05-13T10:47:45.305944Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\"\"\"\n\n ┌──────────────────────────────────┐\n │ •  •  •  •  •  •  •  •  •  •     │  • = anchor centers P3 (8px)\n │                                  │\n │ ○        ○        ○        ○     │  ○ = anchor centers P4 (16px)\n │                                  │\n │ □                 □              │  □ = anchor centers P5 (32px)\n │                                  │\n │ △                                │  △ = anchor centers P6 (64px)\n │                                  │\n │ ☆                                │  ☆ = anchor centers P7 (128px)\n │                                  │\n │                                  │\n │                                  │\n │                                  │\n │                                  │\n └──────────────────────────────────┘\n\n \n Level        Size            Anchors \n ────────────────────────────────────\n P1           256×256         589 824       \n P2           128×128         147 456       \n ────────────────────────────────────\n P3           64×64           36 864   \n P4           32×32           9 216       \n P5           16×16           2 304        \n P6           8×8             576                          \n P7           4×4             144                      \n\n \n (C, H, W) ---> P3 ---> (4*9, H, W) \n (C, H, W) ---> P3 ---> (1*9, H, W) \n \n \n ┌──────────────────────────────────┐\n │                                  │\n │                                  │\n │              ground truth        │\n │              ┌─────────┐         │\n │         #0   │         │         │────► training phase \n │         ┌────┼────────┐│         │      matching (iou, th) \n │         │  #2│        ││         │      \n │    #1   │  ┌─┼─────┐  ││         │      positive ──► box head (smooth l1 -> deltas)\n │    ┌────┼──┼─┼─────┼──┼┼────┐    │               ──► class head (focalloss -> object)      \n │    │    │  │ │ .   │  ││    │    │                     \n │    └────┼──┼─┼─────┼──┼┼────┘    │      negative ──► class head (focalloss → background)\n │         │  └─┼─────┘  ││         │\n │         │    │        ││         │────► inference phase               \n │         └────┼────────┘│         │      non - maximum suppression   \n │              └─────────┘         │\n │                                  │\n │                                  │\n │                                  │\n │                                  │\n └──────────────────────────────────┘\n \n\"\"\"\n\nclass_out = model.class_net(fpn_out)\n\nfor i in range(len(class_out)):\n    print (class_out[i].shape)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:45.308735Z","iopub.execute_input":"2026-05-13T10:47:45.309363Z","iopub.status.idle":"2026-05-13T10:47:45.691038Z","shell.execute_reply.started":"2026-05-13T10:47:45.309325Z","shell.execute_reply":"2026-05-13T10:47:45.689345Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"box_out = model.box_net(fpn_out)\n\nfor i in range(len(box_out)):\n    print (box_out[i].shape)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:45.693299Z","iopub.execute_input":"2026-05-13T10:47:45.693695Z","iopub.status.idle":"2026-05-13T10:47:46.064963Z","shell.execute_reply.started":"2026-05-13T10:47:45.693653Z","shell.execute_reply":"2026-05-13T10:47:46.063625Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class SmoothL1:\n    \n    \"\"\"\n    \n    SmoothL1 Loss or Huber Loss \n    \n    \"\"\"\n    \n    def __init__(self, beta=1.0):\n        self.beta = beta\n\n    def __call__(self, predictions, targets):\n        \n        diff = torch.abs(targets - predictions)\n        mask = diff < self.beta\n        \n        loss_small = 0.5 * (diff ** 2)\n        loss_large = diff - 0.5 * self.beta\n        \n        loss = torch.where(mask, \n                           loss_small, \n                           loss_large)\n        \n        return loss.mean()\n\n    def gradient(self, predictions, targets):\n        \n        diff = predictions - targets\n        mask = torch.abs(diff) < self.beta\n        \n        grad_small = diff ## mse, .5 * x ** 2     \n        grad_large = torch.sign(diff) ## mae \n        \n        gradient = torch.where(mask, \n                               grad_small, \n                               grad_large)\n        \n        return gradient\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:46.066561Z","iopub.execute_input":"2026-05-13T10:47:46.067057Z","iopub.status.idle":"2026-05-13T10:47:46.079596Z","shell.execute_reply.started":"2026-05-13T10:47:46.067004Z","shell.execute_reply":"2026-05-13T10:47:46.078146Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"## https://www.kaggle.com/code/gpreda/deepfake-starter-kit \n\ndef play_video(name):\n    \n    video_url = open(f'/kaggle/input/competitions/deepfake-detection-challenge/train_sample_videos/{name}','rb').read()\n    data_url = \"data:video/mp4;base64,\" + b64encode(video_url).decode()\n    \n    return HTML(\"\"\"<video width=500 controls><source src=\"%s\" type=\"video/mp4\"></video>\"\"\" % data_url)\n\nfor name in ['aagfhgtpmv.mp4', \n             'aapnvogymq.mp4', \n             'abarnvbtwb.mp4', \n             'abofeumbvv.mp4']:\n    display (play_video(name))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:46.081827Z","iopub.execute_input":"2026-05-13T10:47:46.082299Z","iopub.status.idle":"2026-05-13T10:47:47.022652Z","shell.execute_reply.started":"2026-05-13T10:47:46.082267Z","shell.execute_reply":"2026-05-13T10:47:47.021107Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cap = cv2.VideoCapture('/kaggle/input/competitions/deepfake-detection-challenge/train_sample_videos/aagfhgtpmv.mp4')\n\nprint (cap.get(cv2.CAP_PROP_FPS), \n       cap.get(cv2.CAP_PROP_FRAME_WIDTH), \n       cap.get(cv2.CAP_PROP_FRAME_HEIGHT), \n       cap.get(cv2.CAP_PROP_FRAME_COUNT))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:47.023960Z","iopub.execute_input":"2026-05-13T10:47:47.024489Z","iopub.status.idle":"2026-05-13T10:47:47.153731Z","shell.execute_reply.started":"2026-05-13T10:47:47.024440Z","shell.execute_reply":"2026-05-13T10:47:47.151924Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"frames = []\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    frames.append(frame)\n\nlen(frames), frames[0].shape\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:47.155171Z","iopub.execute_input":"2026-05-13T10:47:47.155553Z","iopub.status.idle":"2026-05-13T10:47:50.088813Z","shell.execute_reply.started":"2026-05-13T10:47:47.155508Z","shell.execute_reply":"2026-05-13T10:47:50.088096Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"## https://www.kaggle.com/code/gpreda/deepfake-starter-kit \n\nclass ObjectDetector():\n    \n    def __init__(self, object_cascade_path):\n        \n        self.objectCascade=cv2.CascadeClassifier(object_cascade_path)\n\n    def detect(self, image, \n               scale_factor=1.3,\n               min_neighbors=5,\n               min_size=(20,20)):\n        \n        rects=self.objectCascade.detectMultiScale(image, \n                                                  scaleFactor=scale_factor, \n                                                  minNeighbors=min_neighbors, \n                                                  minSize=min_size)\n        return rects\n\np = '/kaggle/input/datasets/gpreda/haar-cascades-for-face-detection/'\nface_detector = ObjectDetector(p+'haarcascade_frontalface_default.xml')\neyes_detector = ObjectDetector(p+'haarcascade_eye.xml')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:50.089804Z","iopub.execute_input":"2026-05-13T10:47:50.090114Z","iopub.status.idle":"2026-05-13T10:47:50.175318Z","shell.execute_reply.started":"2026-05-13T10:47:50.090086Z","shell.execute_reply":"2026-05-13T10:47:50.173174Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def detect_objects(image, scale_factor, min_neighbors, min_size):\n    \n    image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n    \n    eyes = eyes_detector.detect(image_gray, \n                                scale_factor=scale_factor, \n                                min_neighbors=min_neighbors, \n                                min_size=(int(min_size[0]/2), int(min_size[1]/2)))\n\n    for x, y, w, h in eyes:\n        cv2.circle(image, (int(x+w/2), int(y+h/2)), (int((w + h)/4)), (0, 0, 255), 3)\n\n    faces = face_detector.detect(image_gray, \n                                 scale_factor=scale_factor, \n                                 min_neighbors=min_neighbors, \n                                 min_size=min_size)\n\n    for x, y, w, h in faces:\n        cv2.rectangle(image, (x, y), (x+w, y+h),(0, 255, 0), 3)\n\n    fig = plt.figure(figsize=(10, 10))\n    ax = fig.add_subplot(111)\n    \n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    ax.imshow(image)\n\ndef extract_image_objects(name):\n    \n    capture_image = cv2.VideoCapture(f'/kaggle/input/competitions/deepfake-detection-challenge/train_sample_videos/{name}') \n    ret, frame = capture_image.read()\n    \n    detect_objects(frame, 1.3, 5, (50, 50)) \n\n\nfor name in ['aagfhgtpmv.mp4', \n             'aapnvogymq.mp4', \n             'abarnvbtwb.mp4', \n             'abofeumbvv.mp4']:\n    extract_image_objects(name)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:47:50.178039Z","iopub.execute_input":"2026-05-13T10:47:50.178507Z","iopub.status.idle":"2026-05-13T10:47:53.201567Z","shell.execute_reply.started":"2026-05-13T10:47:50.178447Z","shell.execute_reply":"2026-05-13T10:47:53.200361Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"frames8 = np.array(frames[:8])\n\nframes8 = frames8.transpose(0, 3, 1, 2)\nframes8 = torch.from_numpy(frames8)\nframes8 = frames8.float() / 255.0\n\nframes8.shape\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T11:03:36.193637Z","iopub.execute_input":"2026-05-13T11:03:36.194886Z","iopub.status.idle":"2026-05-13T11:03:36.685013Z","shell.execute_reply.started":"2026-05-13T11:03:36.194833Z","shell.execute_reply":"2026-05-13T11:03:36.683621Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cnn = models.resnet18(weights=models.ResNet18_Weights.DEFAULT)\ncnn = nn.Sequential(*list(cnn.children())[:-1])\n\nseq1 = cnn(frames8).squeeze()\n\nseq1.shape\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T11:03:38.333801Z","iopub.execute_input":"2026-05-13T11:03:38.335005Z","execution_failed":"2026-05-13T11:03:43.389Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"rnn = nn.GRU(512, 4)\n\nrnn(seq1)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:55:07.410315Z","iopub.execute_input":"2026-05-13T10:55:07.410816Z","iopub.status.idle":"2026-05-13T10:55:07.425225Z","shell.execute_reply.started":"2026-05-13T10:55:07.410781Z","shell.execute_reply":"2026-05-13T10:55:07.424117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"volume1 = np.array(frames[:8])\n\nvolume1 = volume1.transpose(3, 0, 1, 2)\nvolume1 = torch.from_numpy(volume1)\nvolume1 = volume1.float() / 255.0\n\nvolume1.shape\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:48:11.389483Z","iopub.execute_input":"2026-05-13T10:48:11.390065Z","iopub.status.idle":"2026-05-13T10:48:11.753926Z","shell.execute_reply.started":"2026-05-13T10:48:11.390009Z","shell.execute_reply":"2026-05-13T10:48:11.752579Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cnn = nn.Conv3d(3, 5, (3, 3, 3), \n                padding='same')\n\ncnn(volume1).shape\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-05-13T10:48:11.755945Z","iopub.execute_input":"2026-05-13T10:48:11.756330Z","iopub.status.idle":"2026-05-13T10:48:13.076827Z","shell.execute_reply.started":"2026-05-13T10:48:11.756300Z","shell.execute_reply":"2026-05-13T10:48:13.075510Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}