Thomas Chardonnens commited on
Commit
a4a31bd
1 Parent(s): 127130c

testing deployment with HFe

Browse files
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  concrete-ml==1.1.0
2
  gradio
 
 
1
  concrete-ml==1.1.0
2
  gradio
3
+ fastapi
seizure_detection.py CHANGED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+
5
+
6
+ class SeizureDetectionCNN(nn.Module):
7
+ def __init__(self, num_classes=2):
8
+ super(SeizureDetectionCNN, self).__init__()
9
+ self.conv1= nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1) # 32, 224, 224
10
+
11
+ self.pool= nn.MaxPool2d(kernel_size=2, stride=2) # 32, 112, 112
12
+
13
+ self.conv2= nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1) # 64, 112, 112 -> 64, 56, 56
14
+ self.conv3= nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1) # 128, 56, 56 -> 128, 28, 28
15
+ self.conv4= nn.Conv2d(128, 256, kernel_size=3, stride=1, padding=1) # 256, 28, 28 -> 256, 14, 14
16
+
17
+ # Adding Batch Normalization
18
+ self.bn1 = nn.BatchNorm2d(32)
19
+ self.bn2 = nn.BatchNorm2d(64)
20
+ self.bn3 = nn.BatchNorm2d(128)
21
+ self.bn4 = nn.BatchNorm2d(256)
22
+
23
+ self.dropout = nn.Dropout(p=0.5) # Dropout with a probability of 50%
24
+
25
+ self.fc1= nn.Linear(256*14*14, 120)
26
+ self.fc2= nn.Linear(120, 32)
27
+ self.fc3= nn.Linear(32, num_classes)
28
+
29
+ def forward(self, x):
30
+ x = self.pool(F.relu(self.bn1(self.conv1(x)))) # 32, 112, 112
31
+ x = self.pool(F.relu(self.bn2(self.conv2(x)))) # 64, 56, 56
32
+ x = self.pool(F.relu(self.bn3(self.conv3(x)))) # 128, 28, 28
33
+ x = self.pool(F.relu(self.bn4(self.conv4(x)))) # 256, 14, 14
34
+
35
+ x = torch.flatten(x, 1)
36
+ x = self.dropout(F.relu(self.fc1(x))) # Apply dropout
37
+ x = self.dropout(F.relu(self.fc2(x))) # Apply dropout
38
+ x = self.fc3(x)
39
+ return x
seizure_detection/deployment/client.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8519d16d710945ce7470058a783984cffb8f2b1040283daec32e523d5c95736b
3
+ size 7408
seizure_detection/deployment/server.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ad7802d887e387740a2c89c04eb7ba4aafaddd62b3bbaa3a907c8657236ad76
3
+ size 1465254
server.py CHANGED
@@ -9,7 +9,7 @@ from common import SERVER_TMP_PATH
9
  from client_server_interface import FHEServer
10
 
11
  # Load the server object for seizure detection
12
- FHE_SERVER = FHEServer(model_path="path/to/seizure_detection_model")
13
 
14
  def get_server_file_path(name, user_id):
15
  """Get the correct temporary file path for the server.
 
9
  from client_server_interface import FHEServer
10
 
11
  # Load the server object for seizure detection
12
+ FHE_SERVER = FHEServer(model_path="ThomasCdnns/EEG-Seizure-Detection/resolve/main/seizure_detection_model-4.pth")
13
 
14
  def get_server_file_path(name, user_id):
15
  """Get the correct temporary file path for the server.