-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
main.cpp
857 lines (737 loc) · 21.8 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
// realsr implemented with ncnn library
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <clocale>
#if _WIN32
// image decoder and encoder with wic
#include "wic_image.h"
#else // _WIN32
// image decoder and encoder with stb
#define STB_IMAGE_IMPLEMENTATION
#define STBI_NO_PSD
#define STBI_NO_TGA
#define STBI_NO_GIF
#define STBI_NO_HDR
#define STBI_NO_PIC
#define STBI_NO_STDIO
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#endif // _WIN32
#include "webp_image.h"
#if _WIN32
#include <wchar.h>
static wchar_t* optarg = NULL;
static int optind = 1;
static wchar_t getopt(int argc, wchar_t* const argv[], const wchar_t* optstring)
{
if (optind >= argc || argv[optind][0] != L'-')
return -1;
wchar_t opt = argv[optind][1];
const wchar_t* p = wcschr(optstring, opt);
if (p == NULL)
return L'?';
optarg = NULL;
if (p[1] == L':')
{
optind++;
if (optind >= argc)
return L'?';
optarg = argv[optind];
}
optind++;
return opt;
}
static std::vector<int> parse_optarg_int_array(const wchar_t* optarg)
{
std::vector<int> array;
array.push_back(_wtoi(optarg));
const wchar_t* p = wcschr(optarg, L',');
while (p)
{
p++;
array.push_back(_wtoi(p));
p = wcschr(p, L',');
}
return array;
}
#else // _WIN32
#include <unistd.h> // getopt()
static std::vector<int> parse_optarg_int_array(const char* optarg)
{
std::vector<int> array;
array.push_back(atoi(optarg));
const char* p = strchr(optarg, ',');
while (p)
{
p++;
array.push_back(atoi(p));
p = strchr(p, ',');
}
return array;
}
#endif // _WIN32
// ncnn
#include "cpu.h"
#include "gpu.h"
#include "platform.h"
#include "realsr.h"
#include "filesystem_utils.h"
static void print_usage()
{
fprintf(stderr, "Usage: realsr-ncnn-vulkan -i infile -o outfile [options]...\n\n");
fprintf(stderr, " -h show this help\n");
fprintf(stderr, " -v verbose output\n");
fprintf(stderr, " -i input-path input image path (jpg/png/webp) or directory\n");
fprintf(stderr, " -o output-path output image path (jpg/png/webp) or directory\n");
fprintf(stderr, " -s scale upscale ratio (4, default=4)\n");
fprintf(stderr, " -t tile-size tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu\n");
fprintf(stderr, " -m model-path realsr model path (default=models-DF2K_JPEG)\n");
fprintf(stderr, " -g gpu-id gpu device to use (default=auto) can be 0,1,2 for multi-gpu\n");
fprintf(stderr, " -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu\n");
fprintf(stderr, " -x enable tta mode\n");
fprintf(stderr, " -f format output image format (jpg/png/webp, default=ext/png)\n");
}
class Task
{
public:
int id;
int webp;
path_t inpath;
path_t outpath;
ncnn::Mat inimage;
ncnn::Mat outimage;
};
class TaskQueue
{
public:
TaskQueue()
{
}
void put(const Task& v)
{
lock.lock();
while (tasks.size() >= 8) // FIXME hardcode queue length
{
condition.wait(lock);
}
tasks.push(v);
lock.unlock();
condition.signal();
}
void get(Task& v)
{
lock.lock();
while (tasks.size() == 0)
{
condition.wait(lock);
}
v = tasks.front();
tasks.pop();
lock.unlock();
condition.signal();
}
private:
ncnn::Mutex lock;
ncnn::ConditionVariable condition;
std::queue<Task> tasks;
};
TaskQueue toproc;
TaskQueue tosave;
class LoadThreadParams
{
public:
int scale;
int jobs_load;
// session data
std::vector<path_t> input_files;
std::vector<path_t> output_files;
};
void* load(void* args)
{
const LoadThreadParams* ltp = (const LoadThreadParams*)args;
const int count = ltp->input_files.size();
const int scale = ltp->scale;
#pragma omp parallel for schedule(static,1) num_threads(ltp->jobs_load)
for (int i=0; i<count; i++)
{
const path_t& imagepath = ltp->input_files[i];
int webp = 0;
unsigned char* pixeldata = 0;
int w;
int h;
int c;
#if _WIN32
FILE* fp = _wfopen(imagepath.c_str(), L"rb");
#else
FILE* fp = fopen(imagepath.c_str(), "rb");
#endif
if (fp)
{
// read whole file
unsigned char* filedata = 0;
int length = 0;
{
fseek(fp, 0, SEEK_END);
length = ftell(fp);
rewind(fp);
filedata = (unsigned char*)malloc(length);
if (filedata)
{
fread(filedata, 1, length, fp);
}
fclose(fp);
}
if (filedata)
{
pixeldata = webp_load(filedata, length, &w, &h, &c);
if (pixeldata)
{
webp = 1;
}
else
{
// not webp, try jpg png etc.
#if _WIN32
pixeldata = wic_decode_image(imagepath.c_str(), &w, &h, &c);
#else // _WIN32
pixeldata = stbi_load_from_memory(filedata, length, &w, &h, &c, 0);
if (pixeldata)
{
// stb_image auto channel
if (c == 1)
{
// grayscale -> rgb
stbi_image_free(pixeldata);
pixeldata = stbi_load_from_memory(filedata, length, &w, &h, &c, 3);
c = 3;
}
else if (c == 2)
{
// grayscale + alpha -> rgba
stbi_image_free(pixeldata);
pixeldata = stbi_load_from_memory(filedata, length, &w, &h, &c, 4);
c = 4;
}
}
#endif // _WIN32
}
free(filedata);
}
}
if (pixeldata)
{
Task v;
v.id = i;
v.inpath = imagepath;
v.outpath = ltp->output_files[i];
v.inimage = ncnn::Mat(w, h, (void*)pixeldata, (size_t)c, c);
v.outimage = ncnn::Mat(w * scale, h * scale, (size_t)c, c);
path_t ext = get_file_extension(v.outpath);
if (c == 4 && (ext == PATHSTR("jpg") || ext == PATHSTR("JPG") || ext == PATHSTR("jpeg") || ext == PATHSTR("JPEG")))
{
path_t output_filename2 = ltp->output_files[i] + PATHSTR(".png");
v.outpath = output_filename2;
#if _WIN32
fwprintf(stderr, L"image %ls has alpha channel ! %ls will output %ls\n", imagepath.c_str(), imagepath.c_str(), output_filename2.c_str());
#else // _WIN32
fprintf(stderr, "image %s has alpha channel ! %s will output %s\n", imagepath.c_str(), imagepath.c_str(), output_filename2.c_str());
#endif // _WIN32
}
toproc.put(v);
}
else
{
#if _WIN32
fwprintf(stderr, L"decode image %ls failed\n", imagepath.c_str());
#else // _WIN32
fprintf(stderr, "decode image %s failed\n", imagepath.c_str());
#endif // _WIN32
}
}
return 0;
}
class ProcThreadParams
{
public:
const RealSR* realsr;
};
void* proc(void* args)
{
const ProcThreadParams* ptp = (const ProcThreadParams*)args;
const RealSR* realsr = ptp->realsr;
for (;;)
{
Task v;
toproc.get(v);
if (v.id == -233)
break;
realsr->process(v.inimage, v.outimage);
tosave.put(v);
}
return 0;
}
class SaveThreadParams
{
public:
int verbose;
};
void* save(void* args)
{
const SaveThreadParams* stp = (const SaveThreadParams*)args;
const int verbose = stp->verbose;
for (;;)
{
Task v;
tosave.get(v);
if (v.id == -233)
break;
// free input pixel data
{
unsigned char* pixeldata = (unsigned char*)v.inimage.data;
if (v.webp == 1)
{
free(pixeldata);
}
else
{
#if _WIN32
free(pixeldata);
#else
stbi_image_free(pixeldata);
#endif
}
}
int success = 0;
path_t ext = get_file_extension(v.outpath);
if (ext == PATHSTR("webp") || ext == PATHSTR("WEBP"))
{
success = webp_save(v.outpath.c_str(), v.outimage.w, v.outimage.h, v.outimage.elempack, (const unsigned char*)v.outimage.data);
}
else if (ext == PATHSTR("png") || ext == PATHSTR("PNG"))
{
#if _WIN32
success = wic_encode_image(v.outpath.c_str(), v.outimage.w, v.outimage.h, v.outimage.elempack, v.outimage.data);
#else
success = stbi_write_png(v.outpath.c_str(), v.outimage.w, v.outimage.h, v.outimage.elempack, v.outimage.data, 0);
#endif
}
else if (ext == PATHSTR("jpg") || ext == PATHSTR("JPG") || ext == PATHSTR("jpeg") || ext == PATHSTR("JPEG"))
{
#if _WIN32
success = wic_encode_jpeg_image(v.outpath.c_str(), v.outimage.w, v.outimage.h, v.outimage.elempack, v.outimage.data);
#else
success = stbi_write_jpg(v.outpath.c_str(), v.outimage.w, v.outimage.h, v.outimage.elempack, v.outimage.data, 100);
#endif
}
if (success)
{
if (verbose)
{
#if _WIN32
fwprintf(stderr, L"%ls -> %ls done\n", v.inpath.c_str(), v.outpath.c_str());
#else
fprintf(stderr, "%s -> %s done\n", v.inpath.c_str(), v.outpath.c_str());
#endif
}
}
else
{
#if _WIN32
fwprintf(stderr, L"encode image %ls failed\n", v.outpath.c_str());
#else
fprintf(stderr, "encode image %s failed\n", v.outpath.c_str());
#endif
}
}
return 0;
}
#if _WIN32
int wmain(int argc, wchar_t** argv)
#else
int main(int argc, char** argv)
#endif
{
path_t inputpath;
path_t outputpath;
int scale = 4;
std::vector<int> tilesize;
path_t model = PATHSTR("models-DF2K_JPEG");
std::vector<int> gpuid;
int jobs_load = 1;
std::vector<int> jobs_proc;
int jobs_save = 2;
int verbose = 0;
int tta_mode = 0;
path_t format = PATHSTR("png");
#if _WIN32
setlocale(LC_ALL, "");
wchar_t opt;
while ((opt = getopt(argc, argv, L"i:o:s:t:m:g:j:f:vxh")) != (wchar_t)-1)
{
switch (opt)
{
case L'i':
inputpath = optarg;
break;
case L'o':
outputpath = optarg;
break;
case L's':
scale = _wtoi(optarg);
break;
case L't':
tilesize = parse_optarg_int_array(optarg);
break;
case L'm':
model = optarg;
break;
case L'g':
gpuid = parse_optarg_int_array(optarg);
break;
case L'j':
swscanf(optarg, L"%d:%*[^:]:%d", &jobs_load, &jobs_save);
jobs_proc = parse_optarg_int_array(wcschr(optarg, L':') + 1);
break;
case L'f':
format = optarg;
break;
case L'v':
verbose = 1;
break;
case L'x':
tta_mode = 1;
break;
case L'h':
default:
print_usage();
return -1;
}
}
#else // _WIN32
int opt;
while ((opt = getopt(argc, argv, "i:o:s:t:m:g:j:f:vxh")) != -1)
{
switch (opt)
{
case 'i':
inputpath = optarg;
break;
case 'o':
outputpath = optarg;
break;
case 's':
scale = atoi(optarg);
break;
case 't':
tilesize = parse_optarg_int_array(optarg);
break;
case 'm':
model = optarg;
break;
case 'g':
gpuid = parse_optarg_int_array(optarg);
break;
case 'j':
sscanf(optarg, "%d:%*[^:]:%d", &jobs_load, &jobs_save);
jobs_proc = parse_optarg_int_array(strchr(optarg, ':') + 1);
break;
case 'f':
format = optarg;
break;
case 'v':
verbose = 1;
break;
case 'x':
tta_mode = 1;
break;
case 'h':
default:
print_usage();
return -1;
}
}
#endif // _WIN32
if (inputpath.empty() || outputpath.empty())
{
print_usage();
return -1;
}
if (scale != 4)
{
fprintf(stderr, "invalid scale argument\n");
return -1;
}
if (tilesize.size() != (gpuid.empty() ? 1 : gpuid.size()) && !tilesize.empty())
{
fprintf(stderr, "invalid tilesize argument\n");
return -1;
}
for (int i=0; i<(int)tilesize.size(); i++)
{
if (tilesize[i] != 0 && tilesize[i] < 32)
{
fprintf(stderr, "invalid tilesize argument\n");
return -1;
}
}
if (jobs_load < 1 || jobs_save < 1)
{
fprintf(stderr, "invalid thread count argument\n");
return -1;
}
if (jobs_proc.size() != (gpuid.empty() ? 1 : gpuid.size()) && !jobs_proc.empty())
{
fprintf(stderr, "invalid jobs_proc thread count argument\n");
return -1;
}
for (int i=0; i<(int)jobs_proc.size(); i++)
{
if (jobs_proc[i] < 1)
{
fprintf(stderr, "invalid jobs_proc thread count argument\n");
return -1;
}
}
if (!path_is_directory(outputpath))
{
// guess format from outputpath no matter what format argument specified
path_t ext = get_file_extension(outputpath);
if (ext == PATHSTR("png") || ext == PATHSTR("PNG"))
{
format = PATHSTR("png");
}
else if (ext == PATHSTR("webp") || ext == PATHSTR("WEBP"))
{
format = PATHSTR("webp");
}
else if (ext == PATHSTR("jpg") || ext == PATHSTR("JPG") || ext == PATHSTR("jpeg") || ext == PATHSTR("JPEG"))
{
format = PATHSTR("jpg");
}
else
{
fprintf(stderr, "invalid outputpath extension type\n");
return -1;
}
}
if (format != PATHSTR("png") && format != PATHSTR("webp") && format != PATHSTR("jpg"))
{
fprintf(stderr, "invalid format argument\n");
return -1;
}
// collect input and output filepath
std::vector<path_t> input_files;
std::vector<path_t> output_files;
{
if (path_is_directory(inputpath) && path_is_directory(outputpath))
{
std::vector<path_t> filenames;
int lr = list_directory(inputpath, filenames);
if (lr != 0)
return -1;
const int count = filenames.size();
input_files.resize(count);
output_files.resize(count);
path_t last_filename;
path_t last_filename_noext;
for (int i=0; i<count; i++)
{
path_t filename = filenames[i];
path_t filename_noext = get_file_name_without_extension(filename);
path_t output_filename = filename_noext + PATHSTR('.') + format;
// filename list is sorted, check if output image path conflicts
if (filename_noext == last_filename_noext)
{
path_t output_filename2 = filename + PATHSTR('.') + format;
#if _WIN32
fwprintf(stderr, L"both %ls and %ls output %ls ! %ls will output %ls\n", filename.c_str(), last_filename.c_str(), output_filename.c_str(), filename.c_str(), output_filename2.c_str());
#else
fprintf(stderr, "both %s and %s output %s ! %s will output %s\n", filename.c_str(), last_filename.c_str(), output_filename.c_str(), filename.c_str(), output_filename2.c_str());
#endif
output_filename = output_filename2;
}
else
{
last_filename = filename;
last_filename_noext = filename_noext;
}
input_files[i] = inputpath + PATHSTR('/') + filename;
output_files[i] = outputpath + PATHSTR('/') + output_filename;
}
}
else if (!path_is_directory(inputpath) && !path_is_directory(outputpath))
{
input_files.push_back(inputpath);
output_files.push_back(outputpath);
}
else
{
fprintf(stderr, "inputpath and outputpath must be either file or directory at the same time\n");
return -1;
}
}
int prepadding = 0;
if (model.find(PATHSTR("models-DF2K")) != path_t::npos
|| model.find(PATHSTR("models-DF2K_JPEG")) != path_t::npos)
{
prepadding = 10;
}
else
{
fprintf(stderr, "unknown model dir type\n");
return -1;
}
#if _WIN32
wchar_t parampath[256];
wchar_t modelpath[256];
if (scale == 4)
{
swprintf(parampath, 256, L"%s/x4.param", model.c_str());
swprintf(modelpath, 256, L"%s/x4.bin", model.c_str());
}
#else
char parampath[256];
char modelpath[256];
if (scale == 4)
{
sprintf(parampath, "%s/x4.param", model.c_str());
sprintf(modelpath, "%s/x4.bin", model.c_str());
}
#endif
path_t paramfullpath = sanitize_filepath(parampath);
path_t modelfullpath = sanitize_filepath(modelpath);
#if _WIN32
CoInitializeEx(NULL, COINIT_MULTITHREADED);
#endif
ncnn::create_gpu_instance();
if (gpuid.empty())
{
gpuid.push_back(ncnn::get_default_gpu_index());
}
const int use_gpu_count = (int)gpuid.size();
if (jobs_proc.empty())
{
jobs_proc.resize(use_gpu_count, 2);
}
if (tilesize.empty())
{
tilesize.resize(use_gpu_count, 0);
}
int cpu_count = std::max(1, ncnn::get_cpu_count());
jobs_load = std::min(jobs_load, cpu_count);
jobs_save = std::min(jobs_save, cpu_count);
int gpu_count = ncnn::get_gpu_count();
for (int i=0; i<use_gpu_count; i++)
{
if (gpuid[i] < 0 || gpuid[i] >= gpu_count)
{
fprintf(stderr, "invalid gpu device\n");
ncnn::destroy_gpu_instance();
return -1;
}
}
int total_jobs_proc = 0;
for (int i=0; i<use_gpu_count; i++)
{
int gpu_queue_count = ncnn::get_gpu_info(gpuid[i]).compute_queue_count();
jobs_proc[i] = std::min(jobs_proc[i], gpu_queue_count);
total_jobs_proc += jobs_proc[i];
}
for (int i=0; i<use_gpu_count; i++)
{
if (tilesize[i] != 0)
continue;
uint32_t heap_budget = ncnn::get_gpu_device(gpuid[i])->get_heap_budget();
// more fine-grained tilesize policy here
if (model.find(PATHSTR("models-DF2K")) != path_t::npos
|| model.find(PATHSTR("models-DF2K_JPEG")) != path_t::npos)
{
if (heap_budget > 1900)
tilesize[i] = 200;
else if (heap_budget > 550)
tilesize[i] = 100;
else if (heap_budget > 190)
tilesize[i] = 64;
else
tilesize[i] = 32;
}
}
{
std::vector<RealSR*> realsr(use_gpu_count);
for (int i=0; i<use_gpu_count; i++)
{
realsr[i] = new RealSR(gpuid[i], tta_mode);
realsr[i]->load(paramfullpath, modelfullpath);
realsr[i]->scale = scale;
realsr[i]->tilesize = tilesize[i];
realsr[i]->prepadding = prepadding;
}
// main routine
{
// load image
LoadThreadParams ltp;
ltp.scale = scale;
ltp.jobs_load = jobs_load;
ltp.input_files = input_files;
ltp.output_files = output_files;
ncnn::Thread load_thread(load, (void*)<p);
// realsr proc
std::vector<ProcThreadParams> ptp(use_gpu_count);
for (int i=0; i<use_gpu_count; i++)
{
ptp[i].realsr = realsr[i];
}
std::vector<ncnn::Thread*> proc_threads(total_jobs_proc);
{
int total_jobs_proc_id = 0;
for (int i=0; i<use_gpu_count; i++)
{
for (int j=0; j<jobs_proc[i]; j++)
{
proc_threads[total_jobs_proc_id++] = new ncnn::Thread(proc, (void*)&ptp[i]);
}
}
}
// save image
SaveThreadParams stp;
stp.verbose = verbose;
std::vector<ncnn::Thread*> save_threads(jobs_save);
for (int i=0; i<jobs_save; i++)
{
save_threads[i] = new ncnn::Thread(save, (void*)&stp);
}
// end
load_thread.join();
Task end;
end.id = -233;
for (int i=0; i<total_jobs_proc; i++)
{
toproc.put(end);
}
for (int i=0; i<total_jobs_proc; i++)
{
proc_threads[i]->join();
delete proc_threads[i];
}
for (int i=0; i<jobs_save; i++)
{
tosave.put(end);
}
for (int i=0; i<jobs_save; i++)
{
save_threads[i]->join();
delete save_threads[i];
}
}
for (int i=0; i<use_gpu_count; i++)
{
delete realsr[i];
}
realsr.clear();
}
ncnn::destroy_gpu_instance();
return 0;
}