Update ppseg with eigen functions (#238)

* Update ppseg backend support type

* Update ppseg preprocess if condition

* Update README.md

* Update README.md

* Update README.md

* Update ppseg with eigen functions

* Delete old argmax function

* Update README.md

* Delete apply_softmax in ppseg example demo

* Update ppseg code with createFromTensor function

* Delete FDTensor2CVMat function

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update ppseg model.cc with transpose&&softmax in place convert

* Update segmentation_result.md

* Update model.cc

* Update README.md

* Update README.md

Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
huangjianhui
2022-09-22 21:21:47 +08:00
committed by GitHub
parent 5ad7f64a3a
commit 625845c7d6
13 changed files with 237 additions and 204 deletions

View File

@@ -116,5 +116,56 @@ FDDataType Mat::Type() {
}
}
Mat CreateFromTensor(const FDTensor& tensor) {
int type = tensor.dtype;
cv::Mat temp_mat;
FDASSERT(tensor.shape.size() == 3,
"When create FD Mat from tensor, tensor shape should be 3-Dim, HWC "
"layout");
int64_t height = tensor.shape[0];
int64_t width = tensor.shape[1];
int64_t channel = tensor.shape[2];
switch (type) {
case FDDataType::UINT8:
temp_mat = cv::Mat(height, width, CV_8UC(channel),
const_cast<void*>(tensor.Data()));
break;
case FDDataType::INT8:
temp_mat = cv::Mat(height, width, CV_8SC(channel),
const_cast<void*>(tensor.Data()));
break;
case FDDataType::INT16:
temp_mat = cv::Mat(height, width, CV_16SC(channel),
const_cast<void*>(tensor.Data()));
break;
case FDDataType::INT32:
temp_mat = cv::Mat(height, width, CV_32SC(channel),
const_cast<void*>(tensor.Data()));
break;
case FDDataType::FP32:
temp_mat = cv::Mat(height, width, CV_32FC(channel),
const_cast<void*>(tensor.Data()));
break;
case FDDataType::FP64:
temp_mat = cv::Mat(height, width, CV_64FC(channel),
const_cast<void*>(tensor.Data()));
break;
default:
FDASSERT(
false,
"Tensor type %d is not supported While calling CreateFromTensor.",
type);
break;
}
Mat mat = Mat(temp_mat);
return mat;
}
} // namespace vision
} // namespace fastdeploy

View File

@@ -76,5 +76,7 @@ struct FASTDEPLOY_DECL Mat {
Device device = Device::CPU;
};
Mat CreateFromTensor(const FDTensor& tensor);
} // namespace vision
} // namespace fastdeploy