Skip to content

Commit 7db462f

Browse files
committed
Supported tta mode and updated ncnn to be3f978
Signed-off-by: Cocoa <[email protected]>
1 parent ccfc3bf commit 7db462f

File tree

8 files changed

+59
-39
lines changed

8 files changed

+59
-39
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ which cmake
9898
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
9999

100100
# build ncnn
101-
cp -f waifu2x-ncnn-vulkan-macos/waifu2x/CMakeLists-waifu2x-ncnn-vulkan.txt ncnn/CMakeLists.txt
102101
rm -rf ncnn/build && mkdir -p ncnn/build && pushd ncnn/build
103102
cmake -DNCNN_VULKAN=ON -D CMAKE_BUILD_TYPE=Release ..
104103
make -j`sysctl -n hw.ncpu` && make install

waifu2x.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
"$(PROJECT_DIR)/waifu2x/ncnn/lib",
485485
);
486486
MACOSX_DEPLOYMENT_TARGET = 10.10;
487-
MARKETING_VERSION = 1.4;
487+
MARKETING_VERSION = 1.5;
488488
PRODUCT_BUNDLE_IDENTIFIER = "moe.cocoaneko.waifu2x-gui";
489489
PRODUCT_NAME = "$(TARGET_NAME)";
490490
STRINGS_FILE_OUTPUT_ENCODING = "UTF-8";
@@ -522,7 +522,7 @@
522522
"$(PROJECT_DIR)/waifu2x/ncnn/lib",
523523
);
524524
MACOSX_DEPLOYMENT_TARGET = 10.10;
525-
MARKETING_VERSION = 1.4;
525+
MARKETING_VERSION = 1.5;
526526
PRODUCT_BUNDLE_IDENTIFIER = "moe.cocoaneko.waifu2x-gui";
527527
PRODUCT_NAME = "$(TARGET_NAME)";
528528
STRINGS_FILE_OUTPUT_ENCODING = "UTF-8";

waifu2x/Base.lproj/Main.storyboard

Lines changed: 38 additions & 28 deletions
Large diffs are not rendered by default.

waifu2x/CMakeLists-waifu2x-ncnn-vulkan.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ set(SHADER_SPV_HEX_FILES)
7070

7171
compile_shader(waifu2x_preproc.comp)
7272
compile_shader(waifu2x_postproc.comp)
73+
compile_shader(waifu2x_preproc_tta.comp)
74+
compile_shader(waifu2x_postproc_tta.comp)
7375

7476
add_custom_target(generate-spirv DEPENDS ${SHADER_SPV_HEX_FILES})
7577

waifu2x/ViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
@property (weak) IBOutlet NSTabView *processingModeTab;
3333
@property (weak) IBOutlet DragDropTableView *multipleImageTableView;
3434
@property (weak) IBOutlet NSButton *startButton;
35+
@property (weak) IBOutlet NSButton *ttaModeButton;
3536

3637
@end
3738

waifu2x/ViewController.mm

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ @implementation ViewController
3939
@synthesize vramStaticticsLabel;
4040
@synthesize processingModeTab;
4141
@synthesize multipleImageTableView;
42+
@synthesize ttaModeButton;
4243

4344
- (void)viewDidLoad {
4445
[super viewDidLoad];
@@ -226,9 +227,10 @@ - (NSArray *)generateOutputPaths:(NSArray *)inputpaths {
226227
- (void)benchmark {
227228
__block NSMutableArray * result = [[NSMutableArray alloc] init];
228229

229-
int noise = 2;
230-
int scale = 2;
230+
int noise = self.noiseParameter.intValue;
231+
int scale = self.scaleParameter.intValue;
231232
int gpuID = self.gpus[self.gpuIDButton.indexOfSelectedItem].deviceID;
233+
BOOL enableTTAMode = self.ttaModeButton.state == NSControlStateValueOn;
232234
NSArray * models = @[@"models-cunet", @"models-upconv_7_anime_style_art_rgb"];
233235
NSArray<NSNumber *> * tilesizes = @[@(400), @(200), @(100)];
234236
NSArray<NSNumber *> * inputSizes = @[@(200), @(400), @(1000), @(2000), @(4000)];
@@ -266,6 +268,7 @@ - (void)benchmark {
266268
tilesize:tsize
267269
model:model
268270
gpuid:gpuID
271+
tta_mode:enableTTAMode
269272
load_job_num:1
270273
proc_job_num:1
271274
save_job_num:1
@@ -318,6 +321,7 @@ - (void)benchmark {
318321
for (NSString * p in result) {
319322
[resultString appendFormat:@"%@\n", p];
320323
}
324+
[resultString appendFormat:@"\nnoise: %d, scale: %d, gpuid: %d, tta mode: %@\n", noise, scale, gpuID, enableTTAMode ? @"YES" : @"NO"];
321325
[alert setInformativeText:resultString];
322326
[alert setAlertStyle:NSAlertStyleInformational];
323327
[alert beginSheetModalForWindow:[self view].window completionHandler:^(NSModalResponse returnCode) {
@@ -353,6 +357,7 @@ - (IBAction)waifu2x:(NSButton *)sender {
353357
int save_jobs = self.savingJobsParameter.intValue;
354358
NSString * model = [NSString stringWithFormat:@"models-%@", [self.modelButton selectedItem].title];
355359
int gpuID = self.gpus[self.gpuIDButton.indexOfSelectedItem].deviceID;
360+
BOOL enableTTAMode = self.ttaModeButton.state == NSControlStateValueOn;
356361
BOOL isSingleMode = true;
357362

358363
NSArray<NSString *> * inputpaths = nil;
@@ -393,6 +398,7 @@ - (IBAction)waifu2x:(NSButton *)sender {
393398
tilesize:tilesize
394399
model:model
395400
gpuid:gpuID
401+
tta_mode:enableTTAMode
396402
load_job_num:load_jobs
397403
proc_job_num:proc_jobs
398404
save_job_num:save_jobs
@@ -406,18 +412,18 @@ - (IBAction)waifu2x:(NSButton *)sender {
406412
}];
407413

408414
self.isProcessing = NO;
409-
[self allowUserIntereaction:YES];
410415

411-
if (isSingleMode) {
412-
dispatch_async(dispatch_get_main_queue(), ^{
416+
dispatch_async(dispatch_get_main_queue(), ^{
417+
[self allowUserIntereaction:YES];
418+
if (isSingleMode) {
413419
if (!result) {
414420
return;
415421
}
416422

417423
[self.outputImageView setImage:result];
418424
unlink(outputpaths[0].UTF8String);
419-
});
420-
}
425+
}
426+
});
421427
});
422428
}
423429

waifu2x/waifu2xmac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef void (^waifu2xProgressBlock)(int current, int total, NSString * descript
2121
tilesize:(int)tilesize
2222
model:(NSString *)model
2323
gpuid:(int)gpuid
24+
tta_mode:(BOOL)enable_tta_mode
2425
load_job_num:(int)jobs_load
2526
proc_job_num:(int)jobs_proc
2627
save_job_num:(int)jobs_save

waifu2x/waifu2xmac.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ + (NSImage *)input:(NSArray<NSString *> *)inputpaths
244244
tilesize:(int)tilesize
245245
model:(NSString *)model
246246
gpuid:(int)gpuid
247+
tta_mode:(BOOL)enable_tta_mode
247248
load_job_num:(int)jobs_load
248249
proc_job_num:(int)jobs_proc
249250
save_job_num:(int)jobs_save
@@ -362,7 +363,7 @@ + (NSImage *)input:(NSArray<NSString *> *)inputpaths
362363
}
363364

364365
{
365-
Waifu2x waifu2x(gpuid);
366+
Waifu2x waifu2x(gpuid, enable_tta_mode);
366367

367368
if (cb) cb(4, total, NSLocalizedString(@"Loading models...", @""));
368369
waifu2x.load([parampath UTF8String], [modelpath UTF8String]);

0 commit comments

Comments
 (0)