ObjectDetection
class ObjectDetection extends DetectionJob
Traits
Properties
| protected bool | $deleteWhenMissingModels | Ignore this job if the MAIA job does not exist any more. |
from DetectionJob |
| protected string | $tmpDir | Temporary directory for files of this job. |
from DetectionJob |
| protected array | $trainingProposals | Selected training proposals. |
|
| protected string | $knowledgeTransferVolumeUrl | URL of the volume for knowledge transfer (if any). |
|
| protected array | $knowledgeTransferImages | Filenames of the images of the knowledge transfer volume, indexed by their IDs. |
Methods
Create GenericImage instances for the images of this job.
Creates the specified directory if it does not exist.
Get the path to the temporary directory.
Execute a Python command and return the path to a file containing the output.
Parse the output JSON files to get the array of annotations for each image.
Create MAIA annotations from the training proposals.
Create an insert array for a MAIA annotation.
Apply the limit for the maximum number of annotations.
Insert one chunk of the MAIA annotations that should be created into the database.
Update the state of the MAIA job after processing the response.
Execute the job
Determine whether knowledge transfer should be performed in this job.
Generate the training dataset for the object detection model.
Create the JSON file that is the input to the dataset generation script.
Perform training of object detection model.
Downloads the model pretrained weights if they weren't downloaded yet.
Create the JSON file that is the input to the training script.
Perform inference with the trained object detection model.
Create the JSON file that is the input to the inference script.
Build the map from image ID to path of the cached image file.
Dispatch the job to store the object detection results.
Create GenericImage instances for the images of the knowledge transfer volume.
Details
at line 46
__construct(MaiaJob $job)
Create a new instance
in
DetectionJob at line 48
void
failed(Exception $exception)
The job failed to process.
in
DetectionJob at line 60
protected array
getGenericImages()
Create GenericImage instances for the images of this job.
in
DetectionJob at line 76
protected
cleanup()
Clean up temporary data produced by this job.
at line 325
protected
dispatchFailure(Exception $e)
Dispatch the job to notify the BIIGLE instance of a failure.
in
DetectionJob at line 91
protected
createTmpDir()
Create the temporary directory for this request.
in
DetectionJob at line 106
protected
ensureDirectory(string $path)
Creates the specified directory if it does not exist.
at line 333
protected string
getTmpDirPath()
Get the path to the temporary directory.
in
DetectionJob at line 132
protected string
python(string $command, string $log = 'log.txt')
Execute a Python command and return the path to a file containing the output.
in
DetectionJob at line 156
protected array
parseAnnotations(array $images)
Parse the output JSON files to get the array of annotations for each image.
in
DetectionJob at line 188
protected array
parseAnnotationsFile(GenericImage $image)
Parse the output JSON file of a single image.
in
DetectionJob at line 213
protected
createMaiaAnnotations(array $annotations)
Create MAIA annotations from the training proposals.
in
DetectionJob at line 238
protected array
createMaiaAnnotation(array $annotation)
Create an insert array for a MAIA annotation.
in
DetectionJob at line 261
protected array
maybeLimitAnnotations(array $annotations, int $limit)
Apply the limit for the maximum number of annotations.
at line 356
protected
insertAnnotationChunk(array $chunk)
Insert one chunk of the MAIA annotations that should be created into the database.
at line 364
protected
updateJobState()
Update the state of the MAIA job after processing the response.
at line 66
handle()
Execute the job
at line 112
protected bool
shouldUseKnowledgeTransfer()
Determine whether knowledge transfer should be performed in this job.
at line 124
protected array
bundleTrainingProposals(MaiaJob $job)
Bundle the training proposals to be sent to the GPU server.
at line 153
protected string
generateDataset(array $images, array $paths)
Generate the training dataset for the object detection model.
at line 173
protected string
createDatasetJson(array $imagesMap, string $outputJsonPath)
Create the JSON file that is the input to the dataset generation script.
at line 200
protected string
performTraining(string $datasetOutputPath)
Perform training of object detection model.
at line 219
protected
maybeDownloadWeights(string $from, string $to)
Downloads the model pretrained weights if they weren't downloaded yet.
at line 238
protected string
createTrainingJson(string $outputJsonPath)
Create the JSON file that is the input to the training script.
at line 263
protected
performInference(array $images, string $datasetOutputPath, string $trainingOutputPath)
Perform inference with the trained object detection model.
at line 280
protected string
createInferenceJson(array $imagesMap)
Create the JSON file that is the input to the inference script.
at line 302
protected array
buildImagesMap(array $images, array $paths)
Build the map from image ID to path of the cached image file.
at line 317
protected
dispatchResponse(array $annotations)
Dispatch the job to store the object detection results.
at line 343
protected array
getKnowledgeTransferImages()
Create GenericImage instances for the images of the knowledge transfer volume.