Skip to content

Commit 58dc7a0

Browse files
committed
Modify: output while classifying images. File names longer than 17 chars are now truncated.
1 parent 1c45984 commit 58dc7a0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

cmd/deepsort/classify.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ func googleNetClassification(path string, arguments *Arguments, wg *sync.WaitGro
3131

3232
body, _ := ioutil.ReadAll(resp.Body)
3333
parsedResponse := parseResponse(body)
34-
color.Println(color.Yellow("[") + color.Cyan(filepath.Base(path)) + color.Yellow("]") + color.Yellow(" Response: ") + color.Green(parsedResponse))
34+
if len(filepath.Base(path)) > 17 {
35+
name := filepath.Base(path)
36+
truncatedName := name[0:5] + "..." + name[len(name)-9:]
37+
logging.Success(color.Yellow("[")+color.Cyan(truncatedName)+
38+
color.Yellow("]")+color.Yellow(" Response: ")+
39+
color.Green(parsedResponse), "[GoogleNet]")
40+
} else {
41+
logging.Success(color.Yellow("[")+color.Cyan(filepath.Base(path))+
42+
color.Yellow("]")+color.Yellow(" Response: ")+
43+
color.Green(parsedResponse), "[GoogleNet]")
44+
}
3545
if arguments.DryRun != true {
3646
renameFile(path, arguments, parsedResponse)
3747
}
@@ -56,7 +66,17 @@ func resNet50Classification(path string, arguments *Arguments, wg *sync.WaitGrou
5666

5767
body, _ := ioutil.ReadAll(resp.Body)
5868
parsedResponse := parseResponse(body)
59-
color.Println(color.Yellow("[") + color.Cyan(filepath.Base(path)) + color.Yellow("]") + color.Yellow(" Response: ") + color.Green(parsedResponse))
69+
if len(filepath.Base(path)) > 17 {
70+
name := filepath.Base(path)
71+
truncatedName := name[0:5] + "..." + name[len(name)-9:]
72+
logging.Success(color.Yellow("[")+color.Cyan(truncatedName)+
73+
color.Yellow("]")+color.Yellow(" Response: ")+
74+
color.Green(parsedResponse), "[ResNet-50]")
75+
} else {
76+
logging.Success(color.Yellow("[")+color.Cyan(filepath.Base(path))+
77+
color.Yellow("]")+color.Yellow(" Response: ")+
78+
color.Green(parsedResponse), "[ResNet-50]")
79+
}
6080
if arguments.DryRun != true {
6181
renameFile(path, arguments, parsedResponse)
6282
}

0 commit comments

Comments
 (0)