You've already forked LuckyWorld
FT - Write Jsonl file
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#include "Dom/JsonObject.h"
|
||||
#include "Serialization/JsonWriter.h"
|
||||
#include "Serialization/JsonSerializer.h"
|
||||
#include "_Utils/FileUtils.h"
|
||||
|
||||
UEpisodeSubSystem::UEpisodeSubSystem()
|
||||
{
|
||||
@ -57,9 +58,11 @@ void UEpisodeSubSystem::Tick(float DeltaTime)
|
||||
if (DataTransfer) DataTransfer->WriteImageToDisk(CurrentRobot->PhysicsSceneProxy->GetMujocoData().time);
|
||||
EpisodeFrames++;
|
||||
|
||||
if (bIsEpisodeCompleted && CapturedEpisodes <= EpisodesToCapture)
|
||||
if (!bIsEpisodeCompleted) return;
|
||||
|
||||
EndEpisode();
|
||||
if (CapturedEpisodes < EpisodesToCapture)
|
||||
{
|
||||
EndEpisode();
|
||||
StartEpisode();
|
||||
}
|
||||
else
|
||||
@ -122,6 +125,7 @@ void UEpisodeSubSystem::StartTraining(const int32 EpisodesCountIn, FString BaseI
|
||||
void UEpisodeSubSystem::EndTraining()
|
||||
{
|
||||
StopTicking();
|
||||
CreateEpisodesStatsJsonFile();
|
||||
// Create jsonl files
|
||||
}
|
||||
|
||||
@ -138,9 +142,6 @@ void UEpisodeSubSystem::StartEpisode()
|
||||
RobotTransform.GetLocation() + RobotTransform.GetRotation().GetForwardVector() * HardCodedRewardDistanceFromRobotPivot * (FMath::RandBool() ? 1 : -1)
|
||||
};
|
||||
|
||||
// DrawDebugLine(this->GetWorld(), EpisodeRewardZone.GetLocation() + FVector::UpVector * 70, EpisodeRewardZone.GetLocation(), FColor::Red, true);
|
||||
// DrawDebugLine(this->GetWorld(), RobotTransform.GetLocation() + FVector::UpVector * 70, RobotTransform.GetLocation(), FColor::Blue, true);
|
||||
|
||||
// Ask the bot to give a reachable location for the Training Object Transform
|
||||
EpisodeObjectBaseTransform = CurrentRobot->RobotPilotComponent->GetReachableTransform();
|
||||
|
||||
@ -276,7 +277,7 @@ void UEpisodeSubSystem::CreateEpisodeStatJsonLine(const FTrainingEpisodeData& Tr
|
||||
|
||||
// Serialize into FString
|
||||
FString Output;
|
||||
const TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&Output);
|
||||
const TSharedRef< TJsonWriter< TCHAR, TCondensedJsonPrintPolicy<TCHAR> > > Writer = TJsonWriterFactory< TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&Output);
|
||||
FJsonSerializer::Serialize(Root.ToSharedRef(), Writer);
|
||||
EpisodeStatLines.Add(Output);
|
||||
}
|
||||
@ -294,7 +295,8 @@ void UEpisodeSubSystem::ConvertImagesToVideo()
|
||||
void UEpisodeSubSystem::CreateEpisodesStatsJsonFile()
|
||||
{
|
||||
// TODO Do not use FJsonObject - simply concat the FStrings into a file
|
||||
|
||||
UFileUtils::WriteJsonlFile(EpisodeStatLines, FPaths::ProjectSavedDir(), FString("episodes_stats"));
|
||||
|
||||
// Create a jsonl file and store in the correct directory
|
||||
// concat TArray<FString> EpisodeStatLines into a single file
|
||||
// https://huggingface.co/datasets/youliangtan/so100_strawberry_grape/blob/main/meta/episodes_stats.jsonl
|
||||
|
Reference in New Issue
Block a user