reformat code
This commit is contained in:
parent
988abb715f
commit
653ee95311
@ -65,3 +65,10 @@ Usage of record:
|
|||||||
-record-json-path string
|
-record-json-path string
|
||||||
Path where to write json files, use RECORD_JSON_PATH if args not set
|
Path where to write json files, use RECORD_JSON_PATH if args not set
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Useful
|
||||||
|
|
||||||
|
Debug record:
|
||||||
|
|
||||||
|
go run ./cmd/rc-tools display record -mqtt-broker tcp://diabolo.local:1883 -mqtt-username satanas -mqtt-password satanas -mqtt-client-id display-record -mqtt-topic-records car/satanas/part/records
|
||||||
|
|
||||||
|
@ -55,12 +55,11 @@ func main() {
|
|||||||
cli.SetDefaultValueFromEnv(&ociImage, "TRAIN_OCI_IMAGE", "")
|
cli.SetDefaultValueFromEnv(&ociImage, "TRAIN_OCI_IMAGE", "")
|
||||||
cli.SetDefaultValueFromEnv(&bucket, "TRAIN_BUCKET", "")
|
cli.SetDefaultValueFromEnv(&bucket, "TRAIN_BUCKET", "")
|
||||||
|
|
||||||
|
|
||||||
flag.BoolVar(&debug, "debug", false, "Display debug logs")
|
flag.BoolVar(&debug, "debug", false, "Display debug logs")
|
||||||
|
|
||||||
displayFlags := flag.NewFlagSet("display", flag.ExitOnError)
|
displayFlags := flag.NewFlagSet("display", flag.ExitOnError)
|
||||||
|
|
||||||
displayFlags.Usage = func(){
|
displayFlags.Usage = func() {
|
||||||
fmt.Printf("Usage of %s %s:\n", os.Args[0], displayFlags.Name())
|
fmt.Printf("Usage of %s %s:\n", os.Args[0], displayFlags.Name())
|
||||||
fmt.Printf(" camera\n \tLive from car camera\n")
|
fmt.Printf(" camera\n \tLive from car camera\n")
|
||||||
fmt.Printf(" record\n \tLive from published records\n")
|
fmt.Printf(" record\n \tLive from published records\n")
|
||||||
@ -87,15 +86,13 @@ func main() {
|
|||||||
recordFlags.StringVar(&recordTopic, "mqtt-topic-records", os.Getenv("MQTT_TOPIC_RECORDS"), "Mqtt topic that contains record data for training, use MQTT_TOPIC_RECORDS if args not set")
|
recordFlags.StringVar(&recordTopic, "mqtt-topic-records", os.Getenv("MQTT_TOPIC_RECORDS"), "Mqtt topic that contains record data for training, use MQTT_TOPIC_RECORDS if args not set")
|
||||||
recordFlags.StringVar(&recordsPath, "record-path", os.Getenv("RECORD_PATH"), "Path where to write records files, use RECORD_PATH if args not set")
|
recordFlags.StringVar(&recordsPath, "record-path", os.Getenv("RECORD_PATH"), "Path where to write records files, use RECORD_PATH if args not set")
|
||||||
|
|
||||||
|
|
||||||
var basedir, destdir string
|
var basedir, destdir string
|
||||||
impdkFlags := flag.NewFlagSet("import-donkey-records", flag.ExitOnError)
|
impdkFlags := flag.NewFlagSet("import-donkey-records", flag.ExitOnError)
|
||||||
impdkFlags.StringVar(&basedir, "from", "", "source directory")
|
impdkFlags.StringVar(&basedir, "from", "", "source directory")
|
||||||
impdkFlags.StringVar(&destdir, "to", "", "destination directory")
|
impdkFlags.StringVar(&destdir, "to", "", "destination directory")
|
||||||
|
|
||||||
|
|
||||||
trainingFlags := flag.NewFlagSet("training", flag.ExitOnError)
|
trainingFlags := flag.NewFlagSet("training", flag.ExitOnError)
|
||||||
trainingFlags.Usage = func(){
|
trainingFlags.Usage = func() {
|
||||||
fmt.Printf("Usage of %s %s:\n", os.Args[0], trainingFlags.Name())
|
fmt.Printf("Usage of %s %s:\n", os.Args[0], trainingFlags.Name())
|
||||||
fmt.Printf(" list\n \tList existing training jobs\n")
|
fmt.Printf(" list\n \tList existing training jobs\n")
|
||||||
fmt.Printf(" archive\n \tBuild tar.gz archive for training\n")
|
fmt.Printf(" archive\n \tBuild tar.gz archive for training\n")
|
||||||
@ -133,7 +130,6 @@ func main() {
|
|||||||
trainArchiveFlags.IntVar(&horizon, "horizon", 0, "Upper zone image to crop (in pixels)")
|
trainArchiveFlags.IntVar(&horizon, "horizon", 0, "Upper zone image to crop (in pixels)")
|
||||||
trainArchiveFlags.BoolVar(&withFlipImage, "with-flip-image", withFlipImage, "Flip horiontal image and reverse steering to increase data into training archive")
|
trainArchiveFlags.BoolVar(&withFlipImage, "with-flip-image", withFlipImage, "Flip horiontal image and reverse steering to increase data into training archive")
|
||||||
|
|
||||||
|
|
||||||
modelsFlags := flag.NewFlagSet("models", flag.ExitOnError)
|
modelsFlags := flag.NewFlagSet("models", flag.ExitOnError)
|
||||||
modelsFlags.Usage = func() {
|
modelsFlags.Usage = func() {
|
||||||
fmt.Printf("Usage of %s %s:\n", os.Args[0], modelsFlags.Name())
|
fmt.Printf("Usage of %s %s:\n", os.Args[0], modelsFlags.Name())
|
||||||
@ -228,7 +224,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
switch trainingFlags.Arg(0) {
|
switch trainingFlags.Arg(0) {
|
||||||
case trainingListJobFlags.Name():
|
case trainingListJobFlags.Name():
|
||||||
if err:= trainingListJobFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
if err := trainingListJobFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
||||||
trainingListJobFlags.PrintDefaults()
|
trainingListJobFlags.PrintDefaults()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
@ -249,7 +245,6 @@ func main() {
|
|||||||
trainingFlags.PrintDefaults()
|
trainingFlags.PrintDefaults()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
case modelsFlags.Name():
|
case modelsFlags.Name():
|
||||||
|
|
||||||
@ -259,13 +254,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
switch modelsFlags.Arg(0) {
|
switch modelsFlags.Arg(0) {
|
||||||
case modelsListFlags.Name():
|
case modelsListFlags.Name():
|
||||||
if err:= modelsListFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
if err := modelsListFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
||||||
modelsListFlags.PrintDefaults()
|
modelsListFlags.PrintDefaults()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
runModelsList(bucket)
|
runModelsList(bucket)
|
||||||
case modelsDownloadFlags.Name():
|
case modelsDownloadFlags.Name():
|
||||||
if err:= modelsDownloadFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
if err := modelsDownloadFlags.Parse(os.Args[3:]); err == flag.ErrHelp {
|
||||||
modelsDownloadFlags.PrintDefaults()
|
modelsDownloadFlags.PrintDefaults()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
@ -320,7 +315,7 @@ func runImportDonkeyRecords(basedir, destdir string) {
|
|||||||
zap.S().Fatalf("unable to import files from %v to %v: %v", basedir, destdir, err)
|
zap.S().Fatalf("unable to import files from %v to %v: %v", basedir, destdir, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func runDisplayRecord(client mqtt.Client, recordTopic string){
|
func runDisplayRecord(client mqtt.Client, recordTopic string) {
|
||||||
r := display.NewRecordDisplay(client, recordTopic)
|
r := display.NewRecordDisplay(client, recordTopic)
|
||||||
defer r.Stop()
|
defer r.Stop()
|
||||||
|
|
||||||
@ -407,4 +402,4 @@ func runModelsDownload(bucketName, modelPath, output string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
zap.S().Fatalf("unable to download model: %s", err)
|
zap.S().Fatalf("unable to download model: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func addJsonFiles(recordFiles []string, imgCam []string, flipImage bool, w *zip.
|
|||||||
if flipImage {
|
if flipImage {
|
||||||
rcd.UserAngle = rcd.UserAngle * -1
|
rcd.UserAngle = rcd.UserAngle * -1
|
||||||
rcd.CamImageArray = fmt.Sprintf("flip_%s", camName)
|
rcd.CamImageArray = fmt.Sprintf("flip_%s", camName)
|
||||||
}else {
|
} else {
|
||||||
rcd.CamImageArray = camName
|
rcd.CamImageArray = camName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ func (r *Record) drawRecord(rec *events.RecordMessage, objects *events.ObjectsMe
|
|||||||
r.window.WaitKey(1)
|
r.window.WaitKey(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *Record) drawSteering(img *gocv.Mat, steering float32) {
|
func (r *Record) drawSteering(img *gocv.Mat, steering float32) {
|
||||||
gocv.PutText(
|
gocv.PutText(
|
||||||
img,
|
img,
|
||||||
|
@ -20,10 +20,10 @@ func ListModels(ctx context.Context, bucket string) error {
|
|||||||
outputs, err := client.ListObjectsV2(
|
outputs, err := client.ListObjectsV2(
|
||||||
ctx,
|
ctx,
|
||||||
&s3.ListObjectsV2Input{
|
&s3.ListObjectsV2Input{
|
||||||
Bucket: aws.String(bucket),
|
Bucket: aws.String(bucket),
|
||||||
Prefix: aws.String("output"),
|
Prefix: aws.String("output"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to list models in bucket %v: %w", bucket, err)
|
return fmt.Errorf("unable to list models in bucket %v: %w", bucket, err)
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ func DownloadArchive(ctx context.Context, bucketName, modelPath string) ([]byte,
|
|||||||
l := zap.S().With(
|
l := zap.S().With(
|
||||||
"bucket", bucketName,
|
"bucket", bucketName,
|
||||||
"model", modelPath,
|
"model", modelPath,
|
||||||
)
|
)
|
||||||
client := s3.NewFromConfig(awsutils.MustLoadConfig())
|
client := s3.NewFromConfig(awsutils.MustLoadConfig())
|
||||||
|
|
||||||
l.Debug("download model")
|
l.Debug("download model")
|
||||||
@ -46,8 +46,8 @@ func DownloadArchive(ctx context.Context, bucketName, modelPath string) ([]byte,
|
|||||||
ctx,
|
ctx,
|
||||||
|
|
||||||
&s3.GetObjectInput{
|
&s3.GetObjectInput{
|
||||||
Bucket: aws.String(bucketName),
|
Bucket: aws.String(bucketName),
|
||||||
Key: aws.String(modelPath),
|
Key: aws.String(modelPath),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to download model: %w", err)
|
return nil, fmt.Errorf("unable to download model: %w", err)
|
||||||
@ -70,4 +70,4 @@ func DownloadArchiveToFile(ctx context.Context, bucketName, modelPath, outputFil
|
|||||||
return fmt.Errorf("unable to write model '%s' to file '%s': %v", modelPath, outputFile, err)
|
return fmt.Errorf("unable to write model '%s' to file '%s': %v", modelPath, outputFile, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package train
|
package train
|
||||||
|
|
||||||
const (
|
const (
|
||||||
prefixInput = "input/data/train/"
|
prefixInput = "input/data/train/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ set +x
|
|||||||
RECORDS_PATH=~/robocar/record-sim4-2
|
RECORDS_PATH=~/robocar/record-sim4-2
|
||||||
#TRAINING_OPTS="--horizon=20"
|
#TRAINING_OPTS="--horizon=20"
|
||||||
TRAINING_OPTS=""
|
TRAINING_OPTS=""
|
||||||
#MODEL_TYPE="categorical"
|
MODEL_TYPE="categorical"
|
||||||
MODEL_TYPE="linear"
|
#MODEL_TYPE="linear"
|
||||||
IMG_WIDTH=160
|
IMG_WIDTH=160
|
||||||
IMG_HEIGHT=120
|
IMG_HEIGHT=120
|
||||||
HORIZON=20
|
HORIZON=20
|
||||||
|
Loading…
Reference in New Issue
Block a user