Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayshuo committed Sep 19, 2024
1 parent 84147aa commit 817ed26
Show file tree
Hide file tree
Showing 4 changed files with 471 additions and 315 deletions.
8 changes: 4 additions & 4 deletions yolov8/include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ nvinfer1::IHostMemory* buildEngineYolov8PoseP6(nvinfer1::IBuilder* builder, nvin
int& max_channels);

nvinfer1::IHostMemory* buildEngineYolov8_5uDet(nvinfer1::IBuilder* builder, nvinfer1::IBuilderConfig* config,
nvinfer1::DataType dt, const std::string& wts_path, float& gd, float& gw,
int& max_channels);

nvinfer1::IHostMemory* buildEngineYolov8_5uDetP6(nvinfer1::IBuilder* builder, nvinfer1::IBuilderConfig* config,
nvinfer1::DataType dt, const std::string& wts_path, float& gd, float& gw,
int& max_channels);

nvinfer1::IHostMemory* buildEngineYolov8_5uDetP6(nvinfer1::IBuilder* builder, nvinfer1::IBuilderConfig* config,
nvinfer1::DataType dt, const std::string& wts_path, float& gd,
float& gw, int& max_channels);
21 changes: 13 additions & 8 deletions yolov8/src/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ std::map<std::string, nvinfer1::Weights> loadWeights(const std::string file) {
std::map<std::string, nvinfer1::Weights> WeightMap;

std::ifstream input(file);
assert(input.is_open() && "Unable to load weight file. please check if the .wts file path is right!!!!!!");
assert(input.is_open() &&
"Unable to load weight file. please check if the "
".wts file path is right!!!!!!");

int32_t count;
input >> count;
Expand Down Expand Up @@ -107,10 +109,13 @@ nvinfer1::ILayer* bottleneck(nvinfer1::INetworkDefinition* network, std::map<std
return conv2;
}


static nvinfer1::ILayer* bottleneck_c3(nvinfer1::INetworkDefinition *network, std::map<std::string, nvinfer1::Weights>& weightMap, nvinfer1::ITensor& input, int c1, int c2, bool shortcut, float e, std::string lname) {
nvinfer1::IElementWiseLayer* cv1 = convBnSiLU(network, weightMap, input, (int)((float)c2 * e), 1, 1, calculateP(1), lname + ".cv1");
nvinfer1::IElementWiseLayer* cv2 = convBnSiLU(network, weightMap, *cv1->getOutput(0), c2, 3, 1, calculateP(3), lname + ".cv2");
static nvinfer1::ILayer* bottleneck_c3(nvinfer1::INetworkDefinition* network,
std::map<std::string, nvinfer1::Weights>& weightMap, nvinfer1::ITensor& input,
int c1, int c2, bool shortcut, float e, std::string lname) {
nvinfer1::IElementWiseLayer* cv1 =
convBnSiLU(network, weightMap, input, (int)((float)c2 * e), 1, 1, calculateP(1), lname + ".cv1");
nvinfer1::IElementWiseLayer* cv2 =
convBnSiLU(network, weightMap, *cv1->getOutput(0), c2, 3, 1, calculateP(3), lname + ".cv2");
if (shortcut && c1 == c2) {
auto ew = network->addElementWise(input, *cv2->getOutput(0), nvinfer1::ElementWiseOperation::kSUM);
return ew;
Expand Down Expand Up @@ -188,14 +193,13 @@ nvinfer1::IElementWiseLayer* C2(nvinfer1::INetworkDefinition* network,
return conv2;
}


nvinfer1::IElementWiseLayer* C3(nvinfer1::INetworkDefinition* network,
std::map<std::string, nvinfer1::Weights> weightMap, nvinfer1::ITensor& input, int c1,
int c2, int n, bool shortcut, float e, std::string lname) {
int c_ = (float)c2 * e;
nvinfer1::IElementWiseLayer* cv1 = convBnSiLU(network, weightMap, input, c_, 1, 1, calculateP(1), lname + ".cv1");
nvinfer1::IElementWiseLayer* cv2 = convBnSiLU(network, weightMap, input, c_, 1, 1, calculateP(1), lname + ".cv2");
nvinfer1::ITensor *y1 = cv1->getOutput(0);
nvinfer1::ITensor* y1 = cv1->getOutput(0);
for (int i = 0; i < n; i++) {
auto b = bottleneck_c3(network, weightMap, *y1, c_, c_, shortcut, 1.0, lname + ".m." + std::to_string(i));
y1 = b->getOutput(0);
Expand Down Expand Up @@ -270,7 +274,8 @@ nvinfer1::IPluginV2Layer* addYoLoLayer(nvinfer1::INetworkDefinition* network,
combinedInfo[6] = is_segmentation;
combinedInfo[7] = is_pose;

// Copy the contents of px_arry into the combinedInfo vector after the initial 5 elements.
// Copy the contents of px_arry into the combinedInfo vector after the initial
// 5 elements.
std::copy(px_arry, px_arry + px_arry_num, combinedInfo.begin() + netinfo_count);

// Now let's create the PluginField object to hold this combined information.
Expand Down
Loading

0 comments on commit 817ed26

Please sign in to comment.