diff --git a/cmd/deepsort/arguments.go b/cmd/deepsort/arguments.go index 2f1981a..6aee9b1 100644 --- a/cmd/deepsort/arguments.go +++ b/cmd/deepsort/arguments.go @@ -11,19 +11,22 @@ import ( func argumentParsing(args []string, argument *Arguments) { // Create new parser object parser := argparse.NewParser("deepsort", "AI powered image tagger backed by DeepDetect") - // Create string flag + // Create flags URL := parser.String("u", "url", &argparse.Options{Required: true, Help: "URL of your DeepDetect instance (i.e: http://localhost:8080)"}) input := parser.String("i", "input", &argparse.Options{Required: true, Help: "Your input folder."}) + dryRun := parser.Flag("d", "dry-run", &argparse.Options{Required: false, Help: "Just classify images and return results, do not apply."}) // Parse input err := parser.Parse(os.Args) if err != nil { // In case of error print error and print usage // This can also be done by passing -h or --help flags fmt.Print(parser.Usage(err)) + os.Exit(0) } // Handle the input flag inputFolder, _ := filepath.Abs(*input) - // Finally print the collected string + // Finally save the collected flags + argument.DryRun = *dryRun argument.Input = inputFolder argument.URL = *URL } diff --git a/cmd/deepsort/classify.go b/cmd/deepsort/classify.go index 465a178..4eadda9 100644 --- a/cmd/deepsort/classify.go +++ b/cmd/deepsort/classify.go @@ -11,10 +11,10 @@ import ( "github.com/labstack/gommon/color" ) -func getClass(path string, arguments *Arguments) { +func googleNetClassification(path string, arguments *Arguments) { url := arguments.URL + "/predict" path, _ = filepath.Abs(path) - var jsonStr = []byte(`{"service":"imageserv","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}`) + var jsonStr = []byte(`{"service":"deepsort-googlenet","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}`) // DEBUG //fmt.Println("Request: " + string(jsonStr)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) diff --git a/cmd/deepsort/main.go b/cmd/deepsort/main.go index e8428a9..b487446 100644 --- a/cmd/deepsort/main.go +++ b/cmd/deepsort/main.go @@ -9,8 +9,9 @@ import ( ) type Arguments struct { - Input string - URL string + Input string + URL string + DryRun bool } func main() { diff --git a/cmd/deepsort/process_recursively.go b/cmd/deepsort/process_recursively.go index a7a4248..a706425 100644 --- a/cmd/deepsort/process_recursively.go +++ b/cmd/deepsort/process_recursively.go @@ -26,7 +26,7 @@ func runRecursively(arguments *Arguments) ([]string, error) { for _, file := range fileList { buf, _ := ioutil.ReadFile(file) if filetype.IsImage(buf) { - getClass(file, arguments) + googleNetClassification(file, arguments) } }