inital commit
This commit is contained in:
commit
438c9d726c
19 changed files with 2169 additions and 0 deletions
70
options.h
Normal file
70
options.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <argp.h>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include "log.h"
|
||||
|
||||
const char *argp_program_version = "AIImagePreprocesses";
|
||||
const char *argp_program_bug_address = "<carl@uvos.xyz>";
|
||||
static char doc[] = "Application that trainsforms images into formats, sizes and aspect ratios required for ai training";
|
||||
static char args_doc[] = "[IMAGES]";
|
||||
|
||||
static struct argp_option options[] =
|
||||
{
|
||||
{"verbose", 'v', 0, 0, "Show debug messages" },
|
||||
{"quiet", 'q', 0, 0, "only output data" },
|
||||
{"model", 'm', "[FILENAME]", 0, "YoloV8 model to use for detection" },
|
||||
{"classes", 'c', "[FILENAME]", 0, "classes text file to use" },
|
||||
{"out", 'o', "[DIRECTORY]", 0, "directory whre images are to be saved" },
|
||||
{"debug", 'd', 0, 0, "output debug images" },
|
||||
{"seam-carving", 's', 0, 0, "model to train: "}
|
||||
};
|
||||
|
||||
struct Config
|
||||
{
|
||||
std::vector<std::filesystem::path> imagePaths;
|
||||
std::filesystem::path modelPath;
|
||||
std::filesystem::path classesPath;
|
||||
std::filesystem::path outputDir;
|
||||
bool seamCarving = false;
|
||||
bool debug = false;
|
||||
};
|
||||
|
||||
static error_t parse_opt (int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
Config *config = reinterpret_cast<Config*>(state->input);
|
||||
switch (key)
|
||||
{
|
||||
case 'q':
|
||||
Log::level = Log::ERROR;
|
||||
break;
|
||||
case 'v':
|
||||
Log::level = Log::DEBUG;
|
||||
break;
|
||||
case 'm':
|
||||
config->modelPath = arg;
|
||||
break;
|
||||
case 'c':
|
||||
config->classesPath = arg;
|
||||
break;
|
||||
case 'd':
|
||||
config->debug = true;
|
||||
break;
|
||||
case 'o':
|
||||
config->outputDir.assign(arg);
|
||||
break;
|
||||
case 's':
|
||||
config->seamCarving = true;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
config->imagePaths.push_back(arg);
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = {options, parse_opt, args_doc, doc};
|
||||
Loading…
Add table
Add a link
Reference in a new issue