{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84969,"databundleVersionId":10033515,"sourceType":"competition"},{"sourceId":9841609,"sourceType":"datasetVersion","datasetId":6037592},{"sourceId":9842409,"sourceType":"datasetVersion","datasetId":6038203},{"sourceId":9842741,"sourceType":"datasetVersion","datasetId":6038460},{"sourceId":9842772,"sourceType":"datasetVersion","datasetId":6038484},{"sourceId":9842888,"sourceType":"datasetVersion","datasetId":6038577}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install gdown\n","metadata":{"execution":{"iopub.status.busy":"2024-11-08T13:54:59.374079Z","iopub.execute_input":"2024-11-08T13:54:59.374607Z","iopub.status.idle":"2024-11-08T13:55:12.857824Z","shell.execute_reply.started":"2024-11-08T13:54:59.374564Z","shell.execute_reply":"2024-11-08T13:55:12.856583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gdown\n\n# Use the correct Google Drive URL format\nfile_url = 'https://drive.google.com/uc?id=1m7EiPi4d_wYCVQ8I9qwPwbhBQNWMoFCm'\noutput_path = '/kaggle/working/mymodel.pth'\n\n# Download the file\ngdown.download(file_url, output_path, quiet=False)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-08T14:00:04.735670Z","iopub.execute_input":"2024-11-08T14:00:04.736325Z","iopub.status.idle":"2024-11-08T14:03:34.246661Z","shell.execute_reply.started":"2024-11-08T14:00:04.736280Z","shell.execute_reply":"2024-11-08T14:03:34.244288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\n\n# Ensure the model architecture is defined\nclass Simple3DModel(nn.Module):\n    def __init__(self):\n        super(Simple3DModel, self).__init__()\n        self.conv1 = nn.Conv3d(1, 16, kernel_size=3, padding=1)\n        self.conv2 = nn.Conv3d(16, 32, kernel_size=3, padding=1)\n        self.pool = nn.MaxPool3d(2)\n\n        self.flattened_size = self._get_flattened_size()\n        self.fc1 = nn.Linear(self.flattened_size, 128)\n        self.fc2 = nn.Linear(128, MAX_PARTICLES * 3)\n\n    def _get_flattened_size(self):\n        sample_input = torch.randn(1, 1, 184, 630, 630)\n        x = self.pool(torch.relu(self.conv1(sample_input)))\n        x = self.pool(torch.relu(self.conv2(x)))\n        return x.view(1, -1).size(1)\n\n    def forward(self, x):\n        x = self.pool(torch.relu(self.conv1(x)))\n        x = self.pool(torch.relu(self.conv2(x)))\n        x = x.view(x.size(0), -1)\n        x = torch.relu(self.fc1(x))\n        x = self.fc2(x)\n\n        if x.size(1) != MAX_PARTICLES * 3:\n            raise ValueError(f\"Output size {x.size(1)} does not match expected {MAX_PARTICLES * 3}\")\n\n        x = x.view(x.size(0), MAX_PARTICLES, 3)\n        return x\n\n# Create a model instance\nmodel = Simple3DModel()\n\n# Load the saved model weights\nmodel.load_state_dict(torch.load('/kaggle/working/mymodel.pth'))  # Update with the actual path in Kaggle\n\n# Set the model to evaluation mode if you're using it for inference\nmodel.eval()\n","metadata":{"execution":{"iopub.status.busy":"2024-11-08T14:04:27.557350Z","iopub.execute_input":"2024-11-08T14:04:27.557885Z","iopub.status.idle":"2024-11-08T14:04:30.785041Z","shell.execute_reply.started":"2024-11-08T14:04:27.557843Z","shell.execute_reply":"2024-11-08T14:04:30.783590Z"},"trusted":true},"execution_count":null,"outputs":[]}]}