Skip to content

Commit

Permalink
Add: googleNetClassification - Process GoogleNet based image classifi…
Browse files Browse the repository at this point in the history
…cation.

Modify: argumentParsing - Add argument --dry-run.
  • Loading branch information
CorentinB committed Aug 19, 2018
1 parent c3d3509 commit 94c80c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cmd/deepsort/arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions cmd/deepsort/classify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions cmd/deepsort/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
)

type Arguments struct {
Input string
URL string
Input string
URL string
DryRun bool
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/deepsort/process_recursively.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 94c80c6

Please sign in to comment.