Initial commit
Browse files- README.md +43 -0
- Results/airplane1.png +0 -0
- Results/airplane2.png +0 -0
- pointNet.py +46 -0
- pointnet_model.onnx +3 -0
- pointnet_model.pt +3 -0
- tnet.py +43 -0
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# PointNet:
|
| 6 |
+
|
| 7 |
+
PointNet trained on the dataset ShapeNet (airplane), by using the OpenMLCore framework.
|
| 8 |
+
The based Pytorch Code is available in model.py
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
## 📌 Results
|
| 13 |
+
|
| 14 |
+
### Visualisations:
|
| 15 |
+
There are some results after the training on Augmented_Dubai-Satellite_Image_segmentation dataset.
|
| 16 |
+
|
| 17 |
+
#### Airplane subdataset Multiclass:
|
| 18 |
+
| Result 1 | Result 2 |
|
| 19 |
+
| :---: | :---: |
|
| 20 |
+
|  |  |
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## 📊 Metrics & Performances
|
| 26 |
+
|
| 27 |
+
### Performance on ShapeNet (Airplane) dataset:
|
| 28 |
+
There are the performances of the model on the Augmented_Dubai-Satellite_Image_segmentation dataset.
|
| 29 |
+
Please note that, on Dubai Satellite dataset, we have a class imbalance for water(class0), road(class2), Building (class3) for this dataset...
|
| 30 |
+
| Model / Configuration | Accuracy |
|
| 31 |
+
| :--- | :---: |
|
| 32 |
+
| Model V1 | 0.9121 |
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## ⚙️ Model training:
|
| 37 |
+
|
| 38 |
+
I used my personal Framework ( a wrapper of PyTorch) to train the model.
|
| 39 |
+
|
| 40 |
+
### Install the framework:
|
| 41 |
+
```bash
|
| 42 |
+
git clone https://github.com/sebastien-doyez2812/OpenML-core.git
|
| 43 |
+
cd OpenML-core
|
Results/airplane1.png
ADDED
|
Results/airplane2.png
ADDED
|
pointNet.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tnet import Tnet
|
| 2 |
+
import torch
|
| 3 |
+
import torch.nn as nn
|
| 4 |
+
import torch.nn.functional as F
|
| 5 |
+
|
| 6 |
+
class PointNet(nn.Module):
|
| 7 |
+
def __init__(self, input_dims= 3, output_dims=13):
|
| 8 |
+
super().__init__()
|
| 9 |
+
self.input_dims = input_dims
|
| 10 |
+
self.output_dims = output_dims
|
| 11 |
+
self.tnet1 = Tnet(3, 3)
|
| 12 |
+
self.tnet2 = Tnet(64, 64)
|
| 13 |
+
|
| 14 |
+
self.conv1 = nn.Conv1d(3, 64, kernel_size=1)
|
| 15 |
+
self.conv2 = nn.Conv1d(64, 1024, kernel_size=1)
|
| 16 |
+
self.conv3 = nn.Conv1d(1088, 128, kernel_size=1) # 1024 (global) + 64 (local)
|
| 17 |
+
self.conv4 = nn.Conv1d(128, self.output_dims, kernel_size=1)
|
| 18 |
+
|
| 19 |
+
self.bn1 = nn.BatchNorm1d(64)
|
| 20 |
+
self.bn2 = nn.BatchNorm1d(1024)
|
| 21 |
+
self.bn3 = nn.BatchNorm1d(128)
|
| 22 |
+
|
| 23 |
+
def forward(self, x):
|
| 24 |
+
batch_size, _, num_pts = x.shape
|
| 25 |
+
|
| 26 |
+
trans1 = self.tnet1(x) # (B, 3, 3)
|
| 27 |
+
skipped_x1 = x.transpose(2, 1) # (B, N, 3)
|
| 28 |
+
x = torch.bmm(skipped_x1, trans1) # (B, N, 3) x (B, 3, 3) = (B, N, 3)
|
| 29 |
+
x = x.transpose(2, 1) # (B, 3, N)
|
| 30 |
+
x = F.relu(self.bn1(self.conv1(x))) # (B, 64, N)
|
| 31 |
+
|
| 32 |
+
local_feat = x # (B, 64, N)
|
| 33 |
+
trans2 = self.tnet2(x) # (B, 64, 64)
|
| 34 |
+
skipped_x2 = x.transpose(2, 1) # (B, N, 64)
|
| 35 |
+
|
| 36 |
+
x = torch.bmm(skipped_x2, trans2) # (B, N, 64) x (B, 64, 64) = (B, N, 64)
|
| 37 |
+
x = x.transpose(2, 1) # (B, 64, N)
|
| 38 |
+
x = F.relu(self.bn2(self.conv2(x))) # (B, 1064, N)
|
| 39 |
+
|
| 40 |
+
# Max pool:
|
| 41 |
+
global_feat = torch.max(x, dim=2, keepdim=True) [0] # (B, 1024, 1)
|
| 42 |
+
global_feat = global_feat.repeat(1, 1, num_pts) # (B, 1024, N)
|
| 43 |
+
x = torch.cat([global_feat, local_feat], dim=1) # (B, 1088, N)
|
| 44 |
+
x = F.relu(self.bn3(self.conv3(x))) # (B, 128, N)
|
| 45 |
+
x = self.conv4(x) # (B, output_dims, N)
|
| 46 |
+
return x
|
pointnet_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c443d066d0ab84794f7810c6d269fbd52a4189ca200e05f56ca69793a1b45e02
|
| 3 |
+
size 2604643
|
pointnet_model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ae92cf09155c6a488f8c2c4ccc7b42b6f34aac1b255c085b6419f6d6a75bf71
|
| 3 |
+
size 2643382
|
tnet.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
|
| 5 |
+
class Tnet(nn.Module):
|
| 6 |
+
def __init__(self, input_dim, output_dim):
|
| 7 |
+
super(Tnet, self).__init__()
|
| 8 |
+
|
| 9 |
+
self.input_dim = input_dim
|
| 10 |
+
self.output_dim = output_dim
|
| 11 |
+
|
| 12 |
+
# Shared MLP layer = con1d
|
| 13 |
+
self.conv1 = nn.Conv1d(self.input_dim, 64, 1)
|
| 14 |
+
self.conv2 = nn.Conv1d(64, 128, 1)
|
| 15 |
+
self.conv3 = nn.Conv1d(128, 256, 1)
|
| 16 |
+
|
| 17 |
+
self.batch_norm1 = nn.BatchNorm1d(64)
|
| 18 |
+
self.batch_norm2 = nn.BatchNorm1d(128)
|
| 19 |
+
self.batch_norm3 = nn.BatchNorm1d(256)
|
| 20 |
+
self.batch_norm4 = nn.BatchNorm1d(128)
|
| 21 |
+
self.batch_norm5 = nn.BatchNorm1d(64)
|
| 22 |
+
|
| 23 |
+
self.fc1 = nn.Linear(256, 128)
|
| 24 |
+
self.fc2 = nn.Linear(128, 64)
|
| 25 |
+
self.fc3 = nn.Linear(64, self.output_dim * self.output_dim)
|
| 26 |
+
|
| 27 |
+
def forward(self, x):
|
| 28 |
+
batch_size = x.shape[0]
|
| 29 |
+
|
| 30 |
+
x = F.relu(self.batch_norm1(self.conv1(x)))
|
| 31 |
+
x = F.relu(self.batch_norm2(self.conv2(x)))
|
| 32 |
+
x = F.relu(self.batch_norm3(self.conv3(x)))
|
| 33 |
+
|
| 34 |
+
x = torch.max(x, dim=2)[0]
|
| 35 |
+
x = x.view(-1, 256)
|
| 36 |
+
|
| 37 |
+
x = F.relu(self.batch_norm4(self.fc1(x)))
|
| 38 |
+
x = F.relu(self.batch_norm5(self.fc2(x)))
|
| 39 |
+
x = self.fc3(x)
|
| 40 |
+
|
| 41 |
+
identity_matrix = torch.eye(self.output_dim, device=x.device).unsqueeze(0).repeat(batch_size, 1, 1) # (B, output_dim, output_dim)
|
| 42 |
+
x = x.view(-1, self.output_dim, self.output_dim) + identity_matrix
|
| 43 |
+
return x
|