mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
add ramdisk, load AI model to ramdisk and start recognition from it
rewrite zmq to DEALER and ROUTER add GET_USER command to get CurrentUser from Python all auth is on the python side inference run and validate annotations on python
This commit is contained in:
@@ -8,6 +8,7 @@ using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.DTO.Queue;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using LinqToDB;
|
||||
using LinqToDB.Data;
|
||||
@@ -75,7 +76,6 @@ public class GalleryService(
|
||||
var missedAnnotations = new ConcurrentBag<Annotation>();
|
||||
try
|
||||
{
|
||||
|
||||
var prefixLen = Constants.THUMBNAIL_PREFIX.Length;
|
||||
|
||||
var thumbnails = ThumbnailsDirectory.GetFiles()
|
||||
@@ -105,9 +105,37 @@ public class GalleryService(
|
||||
return;
|
||||
|
||||
var detections = (await YoloLabel.ReadFromFile(labelName, cancellationToken)).Select(x => new Detection(fName, x)).ToList();
|
||||
|
||||
//get names and time
|
||||
var fileName = Path.GetFileNameWithoutExtension(file.Name);
|
||||
var strings = fileName.Split("_");
|
||||
var timeStr = strings.LastOrDefault();
|
||||
|
||||
string originalMediaName;
|
||||
TimeSpan time;
|
||||
|
||||
//For some reason, TimeSpan.ParseExact doesn't work on every platform.
|
||||
if (!string.IsNullOrEmpty(timeStr) &&
|
||||
timeStr.Length == 6 &&
|
||||
int.TryParse(timeStr[..1], out var hours) &&
|
||||
int.TryParse(timeStr[1..3], out var minutes) &&
|
||||
int.TryParse(timeStr[3..5], out var seconds) &&
|
||||
int.TryParse(timeStr[5..], out var milliseconds))
|
||||
{
|
||||
time = new TimeSpan(0, hours, minutes, seconds, milliseconds * 100);
|
||||
originalMediaName = fileName[..^7];
|
||||
}
|
||||
else
|
||||
{
|
||||
originalMediaName = fileName;
|
||||
time = TimeSpan.FromSeconds(0);
|
||||
}
|
||||
|
||||
var annotation = new Annotation
|
||||
{
|
||||
Name = fName,
|
||||
Time = time,
|
||||
OriginalMediaName = originalMediaName,
|
||||
Name = file.Name.ToFName(),
|
||||
ImageExtension = Path.GetExtension(file.Name),
|
||||
Detections = detections,
|
||||
CreatedDate = File.GetCreationTimeUtc(file.FullName),
|
||||
@@ -129,18 +157,22 @@ public class GalleryService(
|
||||
logger.LogError(e, $"Failed to generate thumbnail for {file.Name}! Error: {e.Message}");
|
||||
}
|
||||
},
|
||||
new ParallelOptions
|
||||
new ParallelOptions
|
||||
{
|
||||
ProgressFn = async num =>
|
||||
{
|
||||
ProgressFn = async num =>
|
||||
{
|
||||
Console.WriteLine($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}");
|
||||
ProcessedThumbnailsPercentage = imagesCount == 0 ? 0 : Math.Min(100, num * 100 / (double)imagesCount);
|
||||
ThumbnailsUpdate?.Invoke(ProcessedThumbnailsPercentage);
|
||||
await Task.CompletedTask;
|
||||
},
|
||||
CpuUtilPercent = 100,
|
||||
ProgressUpdateInterval = 200
|
||||
});
|
||||
Console.WriteLine($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}");
|
||||
ProcessedThumbnailsPercentage = imagesCount == 0 ? 0 : Math.Min(100, num * 100 / (double)imagesCount);
|
||||
ThumbnailsUpdate?.Invoke(ProcessedThumbnailsPercentage);
|
||||
await Task.CompletedTask;
|
||||
},
|
||||
CpuUtilPercent = 100,
|
||||
ProgressUpdateInterval = 200
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, $"Failed to refresh thumbnails! Error: {e.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user