mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
init
This commit is contained in:
@@ -81,16 +81,7 @@ namespace ImageResizer
|
|||||||
AiAvailabilityState = CheckAiAvailability();
|
AiAvailabilityState = CheckAiAvailability();
|
||||||
Logger.LogInfo($"AI availability checked at startup: {AiAvailabilityState}");
|
Logger.LogInfo($"AI availability checked at startup: {AiAvailabilityState}");
|
||||||
|
|
||||||
// If AI is potentially available, start background initialization (non-blocking)
|
ResizeBatch.SetAiSuperResolutionService(Services.NoOpAiSuperResolutionService.Instance);
|
||||||
if (AiAvailabilityState == AiAvailabilityState.Ready)
|
|
||||||
{
|
|
||||||
_ = InitializeAiServiceAsync(); // Fire and forget - don't block UI
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// AI not available - set NoOp service immediately
|
|
||||||
ResizeBatch.SetAiSuperResolutionService(Services.NoOpAiSuperResolutionService.Instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args);
|
var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args);
|
||||||
|
|
||||||
@@ -109,37 +100,7 @@ namespace ImageResizer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static AiAvailabilityState CheckAiAvailability()
|
private static AiAvailabilityState CheckAiAvailability()
|
||||||
{
|
{
|
||||||
try
|
return AiAvailabilityState.Ready;
|
||||||
{
|
|
||||||
// First check if the platform is ARM64 - AI Super Resolution only works on ARM64
|
|
||||||
if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
|
|
||||||
{
|
|
||||||
return AiAvailabilityState.NotSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Windows AI service model ready state
|
|
||||||
// it's so slow, why?
|
|
||||||
var readyState = Services.WinAiSuperResolutionService.GetModelReadyState();
|
|
||||||
|
|
||||||
// Map AI service state to our availability state
|
|
||||||
switch (readyState)
|
|
||||||
{
|
|
||||||
case Microsoft.Windows.AI.AIFeatureReadyState.Ready:
|
|
||||||
return AiAvailabilityState.Ready;
|
|
||||||
|
|
||||||
case Microsoft.Windows.AI.AIFeatureReadyState.NotReady:
|
|
||||||
return AiAvailabilityState.ModelNotReady;
|
|
||||||
|
|
||||||
case Microsoft.Windows.AI.AIFeatureReadyState.DisabledByUser:
|
|
||||||
case Microsoft.Windows.AI.AIFeatureReadyState.NotSupportedOnCurrentSystem:
|
|
||||||
default:
|
|
||||||
return AiAvailabilityState.NotSupported;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return AiAvailabilityState.NotSupported;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user