mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #16472 from l-bat:cp_vton
Add CP-VTON sample * Support resize from PyTorch * Add CP-VTON sample * Fix downsampling * Fix test * Add model links * Add default args * Speed up resize * Fix TOM link * Add default args * Fix comments * Set aspect ratio for input * Update links * Check files exist
This commit is contained in:
@@ -35,7 +35,7 @@ public:
|
||||
CV_Assert(params.has("zoom_factor_x") && params.has("zoom_factor_y"));
|
||||
}
|
||||
interpolation = params.get<String>("interpolation");
|
||||
CV_Assert(interpolation == "nearest" || interpolation == "bilinear");
|
||||
CV_Assert(interpolation == "nearest" || interpolation == "opencv_linear" || interpolation == "bilinear");
|
||||
|
||||
alignCorners = params.get<bool>("align_corners", false);
|
||||
}
|
||||
@@ -106,14 +106,15 @@ public:
|
||||
|
||||
Mat& inp = inputs[0];
|
||||
Mat& out = outputs[0];
|
||||
if (interpolation == "nearest")
|
||||
if (interpolation == "nearest" || interpolation == "opencv_linear")
|
||||
{
|
||||
InterpolationFlags mode = interpolation == "nearest" ? INTER_NEAREST : INTER_LINEAR;
|
||||
for (size_t n = 0; n < inputs[0].size[0]; ++n)
|
||||
{
|
||||
for (size_t ch = 0; ch < inputs[0].size[1]; ++ch)
|
||||
{
|
||||
resize(getPlane(inp, n, ch), getPlane(out, n, ch),
|
||||
Size(outWidth, outHeight), 0, 0, INTER_NEAREST);
|
||||
Size(outWidth, outHeight), 0, 0, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,6 +980,15 @@ void ONNXImporter::populateNet(Net dstNet)
|
||||
replaceLayerParam(layerParams, "width_scale", "zoom_factor_x");
|
||||
}
|
||||
replaceLayerParam(layerParams, "mode", "interpolation");
|
||||
|
||||
if (layerParams.get<String>("interpolation") == "linear" && framework_name == "pytorch") {
|
||||
layerParams.type = "Resize";
|
||||
Mat scales = getBlob(node_proto, constBlobs, 1);
|
||||
CV_Assert(scales.total() == 4);
|
||||
layerParams.set("interpolation", "opencv_linear");
|
||||
layerParams.set("zoom_factor_y", scales.at<float>(2));
|
||||
layerParams.set("zoom_factor_x", scales.at<float>(3));
|
||||
}
|
||||
}
|
||||
else if (layer_type == "LogSoftmax")
|
||||
{
|
||||
|
||||
@@ -311,6 +311,9 @@ TEST_P(Test_ONNX_layers, Padding)
|
||||
TEST_P(Test_ONNX_layers, Resize)
|
||||
{
|
||||
testONNXModels("resize_nearest");
|
||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
|
||||
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
|
||||
testONNXModels("resize_bilinear");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, MultyInputs)
|
||||
|
||||
Reference in New Issue
Block a user