Skip to content

Commit

Permalink
Merge pull request #64 from TNTwise/master
Browse files Browse the repository at this point in the history
Fix models 4.25+
  • Loading branch information
styler00dollar authored Dec 25, 2024
2 parents 63d5a7b + 293cb8f commit 1b24e33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ By default models are exported with ensemble=False and Fast=True
- 66 = rife-v4.23-beta (ensemble=False)
- 67 = rife-v4.24 (ensemble=False)
- 68 = rife-v4.24 (ensemble=True)
- <strong>NOTICE: Models 4.25 through 4.26-large have issues at some resolutions.</strong>
- 69 = rife-v4.25 (ensemble=False)
- 70 = rife-v4.25-lite (ensemble=False)
- 71 = rife-v4.25-heavy (ensemble=False)
Expand Down
11 changes: 8 additions & 3 deletions RIFE/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,23 @@ static void VS_CC rifeCreate(const VSMap* in, VSMap* out, [[maybe_unused]] void*
break;
case 69:
modelPath += "/rife-v4.25_ensembleFalse";
padding = 64;
break;
case 70:
modelPath += "/rife-v4.25-lite_ensembleFalse";
padding = 128;
break;
case 71:
modelPath += "/rife-v4.25_heavy_beta_ensembleFalse";
padding = 64;
break;
case 72:
modelPath += "/rife-v4.26_ensembleFalse";
padding = 64;
break;
case 73:
modelPath += "/rife-v4.26-large_ensembleFalse";
padding = 64;
break;
case 74:
modelPath += "/sudo_rife4_ensembleFalse_fastTrue";
Expand Down Expand Up @@ -541,11 +546,11 @@ static void VS_CC rifeCreate(const VSMap* in, VSMap* out, [[maybe_unused]] void*
else if (modelPath.find("rife4") != std::string::npos)
rife_v4 = true;
// rife 4.25 and 4.26 require more padding due to extra scales.
if (modelPath.find("rifev4.25") != std::string::npos)
if (modelPath.find("rife-v4.25") != std::string::npos)
padding = 64;
if (modelPath.find("rifev4.25-lite") != std::string::npos)
if (modelPath.find("rife-v4.25-lite") != std::string::npos)
padding = 128;
if (modelPath.find("rifev4.26") != std::string::npos)
if (modelPath.find("rife-v4.26") != std::string::npos)
padding = 64;
else if (modelPath.find("rife") == std::string::npos)
throw "unknown model dir type";
Expand Down
11 changes: 6 additions & 5 deletions RIFE/rife.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// rife implemented with ncnn library

#include "rife.h"
//#include <iostream>

#include <algorithm>
#include <vector>
Expand Down Expand Up @@ -386,8 +387,8 @@ int RIFE::process(const float* src0R, const float* src0G, const float* src0B,
opt.staging_vkallocator = staging_vkallocator;

// pad to 32n
int w_padded = (w + 31) / 32 * 32;
int h_padded = (h + 31) / 32 * 32;
int w_padded = (w + padding - 1) / padding * padding;
int h_padded = (h + padding - 1) / padding * padding;

const size_t in_out_tile_elemsize = opt.use_fp16_storage ? 2u : 4u;

Expand Down Expand Up @@ -1179,9 +1180,9 @@ int RIFE::process_v4(const float* src0R, const float* src0G, const float* src0B,
opt.workspace_vkallocator = blob_vkallocator;
opt.staging_vkallocator = staging_vkallocator;
// padding, the default is 32, but newer rife models require 64
int w_padded, h_padded;
w_padded = (w + padding - 1) / padding * padding;
h_padded = (h + padding - 1) / padding * padding;
// std::cout << "padding: " << padding << std::endl;
int w_padded = (w + padding - 1) / padding * padding;
int h_padded = (h + padding - 1) / padding * padding;


const size_t in_out_tile_elemsize = opt.use_fp16_storage ? 2u : 4u;
Expand Down
2 changes: 1 addition & 1 deletion subprojects/ncnn
Submodule ncnn updated 501 files

0 comments on commit 1b24e33

Please sign in to comment.