Skip to content

Commit a10f4d7

Browse files
committed
Move everything into a single package
1 parent 6866027 commit a10f4d7

File tree

11 files changed

+100
-114
lines changed

11 files changed

+100
-114
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Right now, the only supported installation of DeepDetect that works with DeepSor
2121

2222
Then, download the latest DeepSort release from https://github.com/CorentinB/DeepSort/releases
2323

24-
Unzip your release, rename it `deepsort` and make it executable with:
24+
Unzip your release, rename it `DeepSort` and make it executable with:
2525
```
26-
chmod +x deepsort
26+
chmod +x DeepSort
2727
```
2828

2929
# Usage
@@ -34,10 +34,10 @@ DeepSort support few different parameters, you're obliged to fill two of them:
3434

3535
For more informations, refeer to the helper:
3636
```
37-
./deepsort --help
37+
./DeepSort --help
3838
3939
[-u|--url] is required
40-
usage: deepsort [-h|--help] -u|--url "<value>" -i|--input "<value>"
40+
usage: DeepSort [-h|--help] -u|--url "<value>" -i|--input "<value>"
4141
[-n|--network (resnet-50|googlenet)] [-R|--recursive]
4242
[-j|--jobs <integer>] [-d|--dry-run]
4343
File renamed without changes.

classify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package DeepSort
1+
package main
22

33
import (
44
"encoding/base64"

cmd/deepsort/rename.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

cmd/deepsort/service.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package DeepSort
1+
package main
22

33
import "errors"
44

File renamed without changes.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import (
77
"net/http"
88
"log"
99
"path/filepath"
10-
"github.com/CorentinB/DeepSort"
1110
)
1211

1312
func main() {
1413
start := time.Now()
1514
argumentParsing(os.Args)
1615

1716
// Start a new classification service
18-
var c = DeepSort.ClassificationService{
17+
var c = ClassificationService{
1918
Conn: &http.Client{},
2019
URL: arguments.URL,
2120
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55
"gopkg.in/h2non/filetype.v1"
66
"path/filepath"
77
"os"
8-
"github.com/CorentinB/DeepSort"
98
)
109

11-
func process(c *DeepSort.ClassificationService, fileList []string) {
10+
func process(c *ClassificationService, fileList []string) {
1211
// Process files in the input folder
1312
for _, file := range fileList {
1413
buf, _ := ioutil.ReadFile(file)

rename.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
package DeepSort
1+
package main
22

33
import (
44
"strings"
55
"path/filepath"
66
"crypto/md5"
77
"encoding/hex"
8+
"github.com/labstack/gommon/color"
9+
"os"
10+
"bytes"
811
)
912

1013
var replaceSpace = strings.NewReplacer(" ", "_")
@@ -37,3 +40,52 @@ func formatTags(class []string) string {
3740
result = replaceDoubleQuote.Replace(result)
3841
return result
3942
}
43+
44+
func renameFile(c *ClassificationService,
45+
path string, image []byte, tags []string) {
46+
47+
// Generate file name
48+
newPath, tagPart := FormatFileName(path, image, tags)
49+
50+
name := filepath.Base(path)
51+
52+
// Log file name to console
53+
if len(name) > 19 {
54+
// File name is too long, truncate it
55+
var message bytes.Buffer
56+
57+
// Write first and last path of the file name
58+
truncatedName := name[0:5] + "…" + name[len(name)-9:]
59+
message.WriteString(color.Yellow("[") + color.Cyan(truncatedName) + color.Yellow("]"))
60+
61+
// Write tags
62+
message.WriteString(color.Yellow(" Response: ") + color.Green(tagPart))
63+
64+
logSuccess(message.String(), c.Tag)
65+
} else {
66+
// File name fits in the console
67+
var message bytes.Buffer
68+
69+
// Write file name
70+
message.WriteString(color.Yellow("[") + color.Cyan(name) + color.Yellow("]"))
71+
72+
// Pad to 19 characters
73+
for i := 15 - len(name); i > 0; i-- {
74+
message.WriteByte(' ')
75+
}
76+
77+
message.WriteString(color.Yellow(" Response: ") + color.Green(tagPart))
78+
79+
// Write tag
80+
logSuccess(message.String(), c.Tag)
81+
}
82+
83+
// Rename file
84+
if !arguments.DryRun {
85+
err := os.Rename(path, newPath)
86+
if err != nil {
87+
logError("Unable to rename this file.", "["+filepath.Base(path)+"]")
88+
os.Exit(1)
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)