-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update code to use the new ProcessAnnotatedImage job of biigle/largo
This also fixes #148 because the new job generates feature vectors, too.
- Loading branch information
Showing
15 changed files
with
456 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Biigle\Modules\Maia\Jobs; | ||
|
||
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage; | ||
use Biigle\Modules\Maia\MaiaJob; | ||
use Biigle\Modules\Maia\TrainingProposal; | ||
use Biigle\Modules\Maia\TrainingProposalFeatureVector; | ||
use Biigle\VolumeFile; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class ProcessNoveltyDetectedImage extends ProcessAnnotatedImage | ||
{ | ||
public function __construct( | ||
public VolumeFile $file, | ||
public MaiaJob $maiaJob, | ||
public array $only = [], | ||
public bool $skipFeatureVectors = false, | ||
public ?string $targetDisk = null | ||
) | ||
{ | ||
parent::__construct($file, $only, | ||
skipFeatureVectors: $skipFeatureVectors, | ||
targetDisk: $targetDisk | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getAnnotationQuery(VolumeFile $file): Builder | ||
{ | ||
return TrainingProposal::where('image_id', $file->id) | ||
->where('job_id', $this->maiaJob->id); | ||
} | ||
|
||
/** | ||
* Create the feature vectors based on the Python script output. | ||
*/ | ||
protected function updateOrCreateFeatureVectors(Collection $annotations, \Generator $output): void | ||
{ | ||
$annotations = $annotations->keyBy('id'); | ||
foreach ($output as $row) { | ||
$annotation = $annotations->get($row[0]); | ||
TrainingProposalFeatureVector::updateOrCreate( | ||
['id' => $annotation->id], | ||
[ | ||
'job_id' => $annotation->job_id, | ||
'vector' => $row[1], | ||
] | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.