13 #ifndef mitkSegmentAnythingPythonService_h
14 #define mitkSegmentAnythingPythonService_h
54 std::string checkPointPath,
unsigned int gpuId, std::string backend);
62 itkSetMacro(MitkTempDir, std::string);
63 itkGetConstMacro(MitkTempDir, std::string);
122 void start_python_daemon()
const;
128 void WriteControlFile(
const std::string &statusString)
const;
134 void CreateTempDirs(
const std::string &dirPattern);
140 template <
typename TPixel,
unsigned int VImageDimension>
141 void ITKWriter(
const itk::Image<TPixel, VImageDimension> *image, std::string& outputFilename)
const;
144 std::string m_MitkTempDir;
145 std::string m_PythonPath;
146 std::string m_ModelType;
147 std::string m_CheckpointPath;
148 std::string m_InDir, m_OutDir;
149 std::string m_Backend;
150 std::string m_CurrentUId;
152 const std::string PARENT_TEMP_DIR_PATTERN =
"mitk-sam-XXXXXX";
153 const std::string TRIGGER_FILENAME =
"trigger.csv";
154 const std::string SAM_PYTHON_FILE_NAME =
"run_inference_daemon.py";
155 std::future<void> m_Future;
163 static const std::string
OFF;
#define MITKSEGMENTATION_EXPORT
Image class for storing images.
Segment Anything Model Python process handler class.
static bool CheckStatus()
Checks CurrentStatus enum variable and returns true if daemon is READY (to read files) state,...
static Status CurrentStatus
static void onPythonProcessEvent(itk::Object *, const itk::EventObject &, void *)
Static function to print out everything from itk::EventObject. Used as callback in mitk::ProcessExecu...
void TransferImageToProcess(const Image *inputAtTimeStep, std::string &UId)
Writes image as nifity file with unique id (UId) as file name.
~SegmentAnythingPythonService()
Destroy the Segment Anything Python Service object. Stop the async python process and deletes tempora...
mitkClassMacroItkParent(SegmentAnythingPythonService, itk::Object)
mitkNewMacro5Param(SegmentAnythingPythonService, std::string, std::string, std::string, unsigned int, std::string)
void StopAsyncProcess()
Writes KILL to the control file to stop the daemon process.
void TransferPointsToProcess(const std::string &triggerCSV) const
Writes csv stringstream of points to a csv file for python daemon to read.
void StartAsyncProcess()
Creates temp directories and calls start_python_daemon function async.
SegmentAnythingPythonService(std::string workingDir, std::string modelType, std::string checkPointPath, unsigned int gpuId, std::string backend)
Construct a new Segment Anything Python Service object. Specify working directory,...
MultiLabelSegmentation::Pointer RetrieveImageFromProcess(long timeOut=-1) const
Waits for output nifity file from the daemon to appear and reads it as a mitk::Image.
Find image slices visible on a given plane.
static const std::string KILL
static const std::string OFF
static const std::string CUDA_OUT_OF_MEMORY_ERROR
static const std::string READY
static const std::string TIMEOUT_ERROR