Skip to content

Commit 21d756e

Browse files
committed
Modify: main - Better logging.
1 parent 58dc7a0 commit 21d756e

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

cmd/deepsort/arguments.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/akamensky/argparse"
99
)
1010

11-
func argumentParsing(args []string, argument *Arguments) {
11+
func argumentParsing(args []string, arguments *Arguments) {
1212
// Create new parser object
1313
parser := argparse.NewParser("deepsort", "AI powered image tagger backed by DeepDetect")
1414
// Create flags
@@ -29,10 +29,10 @@ func argumentParsing(args []string, argument *Arguments) {
2929
// Handle the input flag
3030
inputFolder, _ := filepath.Abs(*input)
3131
// Finally save the collected flags
32-
argument.Network = *network
33-
argument.Jobs = *jobs
34-
argument.DryRun = *dryRun
35-
argument.Recursive = *recursive
36-
argument.Input = inputFolder
37-
argument.URL = *URL
32+
arguments.Network = *network
33+
arguments.Jobs = *jobs
34+
arguments.DryRun = *dryRun
35+
arguments.Recursive = *recursive
36+
arguments.Input = inputFolder
37+
arguments.URL = *URL
3838
}

cmd/deepsort/classify.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func googleNetClassification(path string, arguments *Arguments, wg *sync.WaitGro
4545
if arguments.DryRun != true {
4646
renameFile(path, arguments, parsedResponse)
4747
}
48+
arguments.CountDone++
4849
}
4950

5051
func resNet50Classification(path string, arguments *Arguments, wg *sync.WaitGroup) {
@@ -80,4 +81,5 @@ func resNet50Classification(path string, arguments *Arguments, wg *sync.WaitGrou
8081
if arguments.DryRun != true {
8182
renameFile(path, arguments, parsedResponse)
8283
}
84+
arguments.CountDone++
8385
}

cmd/deepsort/main.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ type Arguments struct {
1515
Recursive bool
1616
Jobs int
1717
Network string
18+
CountDone int
1819
}
1920

2021
func main() {
2122
start := time.Now()
2223
arguments := new(Arguments)
24+
arguments.CountDone = 0
2325
arguments.Jobs = 1
2426
argumentParsing(os.Args, arguments)
2527
if arguments.Network == "resnet-50" {
@@ -28,14 +30,18 @@ func main() {
2830
if arguments.Jobs == 1 {
2931
logging.Success("Starting image classification recursively..", "[ResNet-50]")
3032
} else {
31-
logging.Success("Starting image classification recursively with "+string(arguments.Jobs)+" parallel jobs..", "[ResNet-50]")
33+
logging.Success("Starting image classification recursively with "+
34+
color.Green(arguments.Jobs)+
35+
color.Yellow(" parallel jobs.."), "[ResNet-50]")
3236
}
3337
runRecursively(arguments)
3438
} else {
3539
if arguments.Jobs == 1 {
3640
logging.Success("Starting image classification..", "[ResNet-50]")
3741
} else {
38-
logging.Success("Starting image classification with "+string(arguments.Jobs)+" parallel jobs..", "[ResNet-50]")
42+
logging.Success("Starting image classification with "+
43+
color.Green(arguments.Jobs)+
44+
color.Yellow(" parallel jobs.."), "[ResNet-50]")
3945
}
4046
run(arguments)
4147
}
@@ -45,17 +51,24 @@ func main() {
4551
if arguments.Jobs == 1 {
4652
logging.Success("Starting image classification recursively..", "[GoogleNet]")
4753
} else {
48-
logging.Success("Starting image classification recursively with "+string(arguments.Jobs)+" parallel jobs..", "[GoogleNet]")
54+
logging.Success("Starting image classification recursively with "+
55+
color.Green(arguments.Jobs)+
56+
color.Yellow(" parallel jobs.."), "[GoogleNet]")
4957
}
5058
runRecursively(arguments)
5159
} else {
5260
if arguments.Jobs == 1 {
5361
logging.Success("Starting image classification..", "[GoogleNet]")
5462
} else {
55-
logging.Success("Starting image classification with "+string(arguments.Jobs)+" parallel jobs..", "[GoogleNet]")
63+
logging.Success("Starting image classification with "+
64+
color.Green(arguments.Jobs)+
65+
color.Yellow(" parallel jobs.."), "[GoogleNet]")
5666
}
5767
run(arguments)
5868
}
5969
}
60-
color.Println(color.Cyan("Done in ") + color.Yellow(time.Since(start)) + color.Cyan("!"))
70+
logging.Success(color.Yellow(arguments.CountDone)+
71+
color.Cyan(" pictures sorted in ")+
72+
color.Yellow(time.Since(start))+
73+
color.Cyan("!"), color.Cyan("Congrats,"))
6174
}

0 commit comments

Comments
 (0)