Skip to content

Commit 94c80c6

Browse files
committed
Add: googleNetClassification - Process GoogleNet based image classification.
Modify: argumentParsing - Add argument --dry-run.
1 parent c3d3509 commit 94c80c6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

cmd/deepsort/arguments.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ import (
1111
func argumentParsing(args []string, argument *Arguments) {
1212
// Create new parser object
1313
parser := argparse.NewParser("deepsort", "AI powered image tagger backed by DeepDetect")
14-
// Create string flag
14+
// Create flags
1515
URL := parser.String("u", "url", &argparse.Options{Required: true, Help: "URL of your DeepDetect instance (i.e: http://localhost:8080)"})
1616
input := parser.String("i", "input", &argparse.Options{Required: true, Help: "Your input folder."})
17+
dryRun := parser.Flag("d", "dry-run", &argparse.Options{Required: false, Help: "Just classify images and return results, do not apply."})
1718
// Parse input
1819
err := parser.Parse(os.Args)
1920
if err != nil {
2021
// In case of error print error and print usage
2122
// This can also be done by passing -h or --help flags
2223
fmt.Print(parser.Usage(err))
24+
os.Exit(0)
2325
}
2426
// Handle the input flag
2527
inputFolder, _ := filepath.Abs(*input)
26-
// Finally print the collected string
28+
// Finally save the collected flags
29+
argument.DryRun = *dryRun
2730
argument.Input = inputFolder
2831
argument.URL = *URL
2932
}

cmd/deepsort/classify.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"github.com/labstack/gommon/color"
1212
)
1313

14-
func getClass(path string, arguments *Arguments) {
14+
func googleNetClassification(path string, arguments *Arguments) {
1515
url := arguments.URL + "/predict"
1616
path, _ = filepath.Abs(path)
17-
var jsonStr = []byte(`{"service":"imageserv","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}`)
17+
var jsonStr = []byte(`{"service":"deepsort-googlenet","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}`)
1818
// DEBUG
1919
//fmt.Println("Request: " + string(jsonStr))
2020
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))

cmd/deepsort/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
)
1010

1111
type Arguments struct {
12-
Input string
13-
URL string
12+
Input string
13+
URL string
14+
DryRun bool
1415
}
1516

1617
func main() {

cmd/deepsort/process_recursively.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func runRecursively(arguments *Arguments) ([]string, error) {
2626
for _, file := range fileList {
2727
buf, _ := ioutil.ReadFile(file)
2828
if filetype.IsImage(buf) {
29-
getClass(file, arguments)
29+
googleNetClassification(file, arguments)
3030
}
3131
}
3232

0 commit comments

Comments
 (0)