Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Mar 14, 2024
2 parents 00a6eab + 6993664 commit 8506bf8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
16 changes: 8 additions & 8 deletions Damselfly.Core/Services/ImageRecognitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,36 +409,36 @@ private async Task DetectObjects(ImageMetaData metadata)

try
{
var thumbSize = ThumbSize.Large;
var medThumb = new FileInfo(_thumbService.GetThumbPath(fileName, thumbSize));
var thumbSize = ThumbSize.ExtraLarge;
var imgThumb = new FileInfo(_thumbService.GetThumbPath(fileName, thumbSize));

// We need a large thumbnail to do AI processing. Ensure it's been created.
if( ! medThumb.Exists )
if( ! imgThumb.Exists )
{
await _thumbService.CreateThumb(image.ImageId, thumbSize);
if( ! File.Exists( medThumb.FullName ) )
if( ! File.Exists( imgThumb.FullName ) )
{
// If we couldn't create the thumb, bail out.
throw new InvalidOperationException(
$"Unable to run AI processing - {thumbSize} thumbnail doesn't exist: {medThumb}");
$"Unable to run AI processing - {thumbSize} thumbnail doesn't exist: {imgThumb}");
}
}

var enableAIProcessing = _configService.GetBool(ConfigSettings.EnableAIProcessing, true);

MetaDataService.GetImageSize(medThumb.FullName, out var thumbWidth, out var thumbHeight);
MetaDataService.GetImageSize(imgThumb.FullName, out var thumbWidth, out var thumbHeight);

var foundObjects = new List<ImageObject>();
var foundFaces = new List<ImageObject>();

if ( enableAIProcessing )
Logging.Log($"Processing AI image detection for {fileName.Name}...");

if ( !File.Exists(medThumb.FullName) )
if ( !File.Exists(imgThumb.FullName) )
// The thumb isn't ready yet.
return;

using var theImage = SixLabors.ImageSharp.Image.Load<Rgb24>(medThumb.FullName);
using var theImage = SixLabors.ImageSharp.Image.Load<Rgb24>(imgThumb.FullName);

if ( _imageClassifier != null && enableAIProcessing )
{
Expand Down
18 changes: 10 additions & 8 deletions Damselfly.ML.ObjectDetection.ML/ObjectDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ public Task<IList<ImageDetectResult>> DetectObjects(Image<Rgb24> image)
{
if( scorer != null )
{

var watch = new Stopwatch( "DetectObjects" );

var predictions = scorer.Predict( image );

watch.Stop();
// There's a min of 640x640 for the model.
if( image.Width > 640 && image.Height > 640 )
{
var predictions = scorer.Predict( image );

var objectsFound = predictions.Where( x => x.Score > predictionThreshold )
.Select( x => MakeResult( x ) )
.ToList();
watch.Stop();

result = objectsFound;
var objectsFound = predictions.Where( x => x.Score > predictionThreshold )
.Select( x => MakeResult( x ) )
.ToList();

result = objectsFound;
}
}
}
catch ( Exception ex )
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.1.2

0 comments on commit 8506bf8

Please sign in to comment.