Skip to content

Commit

Permalink
remove vision support
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Juhasz committed Dec 28, 2024
1 parent 5a2a931 commit 1efb7a9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 34 deletions.
11 changes: 0 additions & 11 deletions src/PhotoArchiver.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Azure.Storage.Blobs;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -45,16 +44,6 @@

// vision
.Configure<ComputerVisionOptions>(configuration.GetSection("ComputerVision"))
.AddSingleton<IComputerVisionClient>(sp =>
{
var options = sp.GetRequiredService<IOptions<ComputerVisionOptions>>().Value;
var client = new ComputerVisionClient(new Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ApiKeyServiceClientCredentials(options.Key));
if (options.Endpoint != null)
{
client.Endpoint = options.Endpoint.ToString();
}
return client;
})

// face
.Configure<FaceOptions>(configuration.GetSection("Face"))
Expand Down
20 changes: 2 additions & 18 deletions src/PhotoArchiver/Archiver.Upload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using Azure.Storage.Blobs.Specialized;
using MetadataExtractor;
using MetadataExtractor.Formats.QuickTime;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -130,23 +128,9 @@ public async Task<ArchiveResult> ArchiveAsync(IReadOnlyList<IFile> files, IProgr
{
try
{
// create thumbnail
using var thumbnail = await ThumbnailGenerator.GetThumbnailAsync(await item.OpenReadAsync(), 1024, 1024);

// describe
Logger.LogTrace($"Describing {file}...");
var description = await ComputerVisionClient.DescribeImageInStreamAsync(thumbnail, cancellationToken: cancellationToken);
CostEstimator.AddDescribe();
if (description.Captions.Any())
{
item.Metadata.Add("Caption", description.Captions.OrderByDescending(c => c.Confidence).First().Text);
}
if (description.Tags.Any())
{
item.Metadata.Add("Tags", String.Join(", ", description.Tags));
}
throw new NotImplementedException("Vision support has been temporarily removed.");
}
catch (ComputerVisionErrorResponseException ex)
catch (Exception ex)
{
Logger.LogWarning(ex, ex.Message);
}
Expand Down
4 changes: 0 additions & 4 deletions src/PhotoArchiver/Archiver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Azure.Storage;
using Azure.Storage.Blobs;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -29,7 +28,6 @@ public Archiver(
BlobServiceClient client,
IThumbnailGenerator thumbnailGenerator,
IDeduplicationService deduplicationService,
IComputerVisionClient computerVisionClient,
CostEstimator costEstimator,
IProgressIndicator progressIndicator,
ILogger<Archiver> logger
Expand All @@ -43,7 +41,6 @@ ILogger<Archiver> logger
Client = client;
ThumbnailGenerator = thumbnailGenerator;
DeduplicationService = deduplicationService;
ComputerVisionClient = computerVisionClient;
CostEstimator = costEstimator;
ProgressIndicator = progressIndicator;
Logger = logger;
Expand All @@ -57,7 +54,6 @@ ILogger<Archiver> logger
protected BlobServiceClient Client { get; }
protected IThumbnailGenerator ThumbnailGenerator { get; }
protected IDeduplicationService DeduplicationService { get; }
protected IComputerVisionClient ComputerVisionClient { get; }
protected CostEstimator CostEstimator { get; }
protected IProgressIndicator ProgressIndicator { get; }
protected ILogger<Archiver> Logger { get; }
Expand Down
1 change: 0 additions & 1 deletion src/PhotoArchiver/PhotoArchiver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="*" />
<PackageReference Include="MetadataExtractor" Version="2.*" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.*" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down

0 comments on commit 1efb7a9

Please sign in to comment.