@@ -10,13 +10,16 @@ import (
1010
1111 "github.com/CorentinB/DeepSort/pkg/logging"
1212 "github.com/labstack/gommon/color"
13+ "encoding/base64"
14+ "encoding/hex"
15+ "crypto/md5"
1316)
1417
15- func googleNetClassification (path string , arguments * Arguments , wg * sync.WaitGroup ) {
18+ func googleNetClassification (path string , content [] byte , arguments * Arguments , wg * sync.WaitGroup ) {
1619 defer wg .Done ()
1720 url := arguments .URL + "/predict"
18- path , _ = filepath . Abs ( path )
19- var jsonStr = []byte (`{"service":"deepsort-resnet","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}` )
21+ dataStr := base64 . StdEncoding . EncodeToString ( content )
22+ var jsonStr = []byte (`{"service":"deepsort-resnet","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + dataStr + `"]}` )
2023 // DEBUG
2124 //fmt.Println("Request: " + string(jsonStr))
2225 req , err := http .NewRequest ("POST" , url , bytes .NewBuffer (jsonStr ))
@@ -43,16 +46,18 @@ func googleNetClassification(path string, arguments *Arguments, wg *sync.WaitGro
4346 color .Green (parsedResponse ), "[GoogleNet]" )
4447 }
4548 if arguments .DryRun != true {
46- renameFile (path , arguments , parsedResponse )
49+ hashBytes := md5 .Sum (content )
50+ hash := hex .EncodeToString (hashBytes [:])
51+ renameFile (path , hash , arguments , parsedResponse )
4752 }
4853 arguments .CountDone ++
4954}
5055
51- func resNet50Classification (path string , arguments * Arguments , wg * sync.WaitGroup ) {
56+ func resNet50Classification (path string , content [] byte , arguments * Arguments , wg * sync.WaitGroup ) {
5257 defer wg .Done ()
5358 url := arguments .URL + "/predict"
54- path , _ = filepath . Abs ( path )
55- var jsonStr = []byte (`{"service":"deepsort-resnet-50","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + path + `"]}` )
59+ dataStr := base64 . StdEncoding . EncodeToString ( content )
60+ var jsonStr = []byte (`{"service":"deepsort-resnet-50","parameters":{"input":{"width":224,"height":224},"output":{"best":1},"mllib":{"gpu":false}},"data":["` + dataStr + `"]}` )
5661 // DEBUG
5762 //fmt.Println("Request: " + string(jsonStr))
5863 req , err := http .NewRequest ("POST" , url , bytes .NewBuffer (jsonStr ))
@@ -79,7 +84,9 @@ func resNet50Classification(path string, arguments *Arguments, wg *sync.WaitGrou
7984 color .Green (parsedResponse ), "[ResNet-50]" )
8085 }
8186 if arguments .DryRun != true {
82- renameFile (path , arguments , parsedResponse )
87+ hashBytes := md5 .Sum (content )
88+ hash := hex .EncodeToString (hashBytes [:])
89+ renameFile (path , hash , arguments , parsedResponse )
8390 }
8491 arguments .CountDone ++
8592}
0 commit comments