Commit ·
1d001cd
1
Parent(s): f1799a0
ico:增加ico
Browse files- BFDS_train.py +1 -2
- BFDS_web.py +1 -1
- docs/favicon.ico +0 -0
- docs/favicon.png +3 -0
- models/ResNet12.py +0 -96
- models/__init__.py +1 -1
BFDS_train.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import logging
|
| 3 |
import warnings
|
| 4 |
-
import json
|
| 5 |
from datetime import datetime
|
| 6 |
import requests
|
| 7 |
|
|
@@ -38,7 +37,7 @@ class Argument:
|
|
| 38 |
self.normalize_type = None # 归一化方式, mean-std/min-max/None
|
| 39 |
|
| 40 |
# 模型
|
| 41 |
-
self.model_name = "
|
| 42 |
self.bottleneck = True # 是否使用bottleneck层
|
| 43 |
self.bottleneck_num = 256 # bottleneck层的输出维数
|
| 44 |
|
|
|
|
| 1 |
import os
|
| 2 |
import logging
|
| 3 |
import warnings
|
|
|
|
| 4 |
from datetime import datetime
|
| 5 |
import requests
|
| 6 |
|
|
|
|
| 37 |
self.normalize_type = None # 归一化方式, mean-std/min-max/None
|
| 38 |
|
| 39 |
# 模型
|
| 40 |
+
self.model_name = "ResNet" # 模型名
|
| 41 |
self.bottleneck = True # 是否使用bottleneck层
|
| 42 |
self.bottleneck_num = 256 # bottleneck层的输出维数
|
| 43 |
|
BFDS_web.py
CHANGED
|
@@ -403,4 +403,4 @@ with gr.Blocks(title="BFDS WebUI") as app:
|
|
| 403 |
signal_inference_button.click(signal_inference, inputs=[model_file, signal_file_multiple], outputs=signal_inference_output)
|
| 404 |
|
| 405 |
app.queue()
|
| 406 |
-
app.launch()
|
|
|
|
| 403 |
signal_inference_button.click(signal_inference, inputs=[model_file, signal_file_multiple], outputs=signal_inference_output)
|
| 404 |
|
| 405 |
app.queue()
|
| 406 |
+
app.launch(favicon_path="docs/favicon.ico", show_error=True)
|
docs/favicon.ico
ADDED
|
|
docs/favicon.png
ADDED
|
|
Git LFS Details
|
models/ResNet12.py
DELETED
|
@@ -1,96 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
import torch.nn as nn
|
| 3 |
-
from torchsummary import summary
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
class Block(nn.Module):
|
| 7 |
-
def __init__(self, in_planes, planes, stride=1):
|
| 8 |
-
super(Block, self).__init__()
|
| 9 |
-
# 第一个1x1卷积层,用于通道变换
|
| 10 |
-
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False)
|
| 11 |
-
self.bn1 = nn.BatchNorm2d(planes)
|
| 12 |
-
# 第二个3x3卷积层,可能进行下采样
|
| 13 |
-
self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
|
| 14 |
-
self.bn2 = nn.BatchNorm2d(planes)
|
| 15 |
-
# 第三个1x1卷积层,恢复通道数
|
| 16 |
-
self.conv3 = nn.Conv2d(planes, planes, kernel_size=1, bias=False)
|
| 17 |
-
self.bn3 = nn.BatchNorm2d(planes)
|
| 18 |
-
self.relu = nn.ReLU(inplace=True)
|
| 19 |
-
|
| 20 |
-
# 当输入和输出维度不一致时,使用1x1卷积调整
|
| 21 |
-
self.shortcut = nn.Sequential()
|
| 22 |
-
if stride != 1 or in_planes != planes:
|
| 23 |
-
self.shortcut = nn.Sequential(nn.Conv2d(in_planes, planes, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(planes))
|
| 24 |
-
|
| 25 |
-
def forward(self, x):
|
| 26 |
-
identity = self.shortcut(x)
|
| 27 |
-
|
| 28 |
-
out = self.conv1(x)
|
| 29 |
-
out = self.bn1(out)
|
| 30 |
-
out = self.relu(out)
|
| 31 |
-
|
| 32 |
-
out = self.conv2(out)
|
| 33 |
-
out = self.bn2(out)
|
| 34 |
-
out = self.relu(out)
|
| 35 |
-
|
| 36 |
-
out = self.conv3(out)
|
| 37 |
-
out = self.bn3(out)
|
| 38 |
-
|
| 39 |
-
out += identity
|
| 40 |
-
out = self.relu(out)
|
| 41 |
-
return out
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
class ResNet12(nn.Module):
|
| 45 |
-
def __init__(self):
|
| 46 |
-
super(ResNet12, self).__init__()
|
| 47 |
-
self.__in_features = 256
|
| 48 |
-
self.in_planes = 64 # 初始通道数
|
| 49 |
-
|
| 50 |
-
# 初始卷积层
|
| 51 |
-
self.conv1 = nn.Conv2d(in_channels=1, out_channels=64, kernel_size=3, stride=1, padding=1, bias=False)
|
| 52 |
-
self.bn1 = nn.BatchNorm2d(64)
|
| 53 |
-
self.relu = nn.ReLU(inplace=True)
|
| 54 |
-
|
| 55 |
-
# 四个残差块层
|
| 56 |
-
self.layer1 = self._make_layer(64, stride=1) # 第1层,不降采样
|
| 57 |
-
self.layer2 = self._make_layer(128, stride=2) # 第2层,降采样
|
| 58 |
-
self.layer3 = self._make_layer(256, stride=2) # 第3层,降采样
|
| 59 |
-
self.layer4 = self._make_layer(512, stride=2) # 第4层,降采样
|
| 60 |
-
|
| 61 |
-
# 分类层
|
| 62 |
-
self.avgpool = nn.AdaptiveAvgPool2d(1)
|
| 63 |
-
self.fc = nn.Linear(512, self.__in_features) # 输出特征维度为256
|
| 64 |
-
|
| 65 |
-
def _make_layer(self, planes, stride):
|
| 66 |
-
# 每个残差块层包含一个Block
|
| 67 |
-
layers = []
|
| 68 |
-
layers.append(Block(self.in_planes, planes, stride))
|
| 69 |
-
self.in_planes = planes # 更新输入通道数为当前层的输出通道数
|
| 70 |
-
return nn.Sequential(*layers)
|
| 71 |
-
|
| 72 |
-
def forward(self, x):
|
| 73 |
-
out = self.conv1(x)
|
| 74 |
-
out = self.bn1(out)
|
| 75 |
-
out = self.relu(out)
|
| 76 |
-
|
| 77 |
-
out = self.layer1(out)
|
| 78 |
-
out = self.layer2(out)
|
| 79 |
-
out = self.layer3(out)
|
| 80 |
-
out = self.layer4(out)
|
| 81 |
-
|
| 82 |
-
out = self.avgpool(out)
|
| 83 |
-
out = out.view(out.size(0), -1)
|
| 84 |
-
out = self.fc(out)
|
| 85 |
-
return out
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
def output_num(self):
|
| 89 |
-
return self.__in_features
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
# 测试代码
|
| 93 |
-
if __name__ == "__main__":
|
| 94 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 95 |
-
model = ResNet12(num_classes=5).to(device)
|
| 96 |
-
summary(model, (1, 224, 224))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
from models.CNN import CNN as CNN
|
| 2 |
-
from models.ResNet18_1d import ResNet1D as
|
|
|
|
| 1 |
from models.CNN import CNN as CNN
|
| 2 |
+
from models.ResNet18_1d import ResNet1D as ResNet
|