2023-02-01 22:30:00 +09:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2023-02-02 19:02:36 +09:00
|
|
|
#include "uNet.h"
|
2023-02-01 22:30:00 +09:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
// Global variables
|
|
|
|
int N = 1;
|
|
|
|
int random_seed = 1;
|
|
|
|
int print_max = 8;
|
|
|
|
int MAX_LEN = 10;
|
|
|
|
char *parameter_fname;
|
|
|
|
char *output_fname;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
check_and_parse_args(argc, argv);
|
|
|
|
|
|
|
|
// Initialize model
|
|
|
|
styler_initialize(N, random_seed, parameter_fname);
|
|
|
|
|
|
|
|
float *random_floats = nullptr;
|
|
|
|
char *output = nullptr;
|
|
|
|
|
|
|
|
// Initialize input and output
|
|
|
|
random_floats = (float *)malloc(N * MAX_LEN * sizeof(float));
|
|
|
|
output = (char *)malloc(N * (MAX_LEN + 1) * sizeof(char));
|
|
|
|
srand(random_seed);
|
|
|
|
for (int i = 0; i < N * MAX_LEN; i++) {
|
|
|
|
random_floats[i] = ((float)rand()) / ((float)RAND_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Styling %d images...", N);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
// Styling images and measure time
|
|
|
|
double styler_st = get_time();
|
|
|
|
|
|
|
|
styler(N, random_floats, output);
|
|
|
|
|
|
|
|
double styler_en = get_time();
|
|
|
|
|
|
|
|
double elapsed_time = styler_en - styler_st;
|
|
|
|
printf("Done!\n");
|
|
|
|
|
|
|
|
// Print first few result
|
|
|
|
print_first_few_result(output, print_max, elapsed_time);
|
|
|
|
|
|
|
|
// Finalize program
|
|
|
|
styler_finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|