Skip to content

Commit

Permalink
Image Analysis SDK: Post-release updates, re-emitting SDK with latest…
Browse files Browse the repository at this point in the history
… TypeSpec files (no public API changes) (#38471)
  • Loading branch information
dargilco authored Jan 26, 2024
1 parent 5068166 commit 8e29482
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 218 deletions.
4 changes: 1 addition & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
/sdk/openai/azure-ai-openai/ @brandom-msft @jpalvarezl @mssfang

# PRLabel: %Image Analysis
# ServiceLabel: %Image Analysis %Service Attention
/sdk/vision/azure-ai-vision-imageanalysis/ @dargilco @rhurey

# PRLabel: %Remote Rendering
Expand Down Expand Up @@ -473,9 +474,6 @@
# ServiceLabel: %HPC Cache %Service Attention
#/<NotInRepo>/ @romahamu @omzevall

# ServiceLabel: %Image Analysis %Service Attention
#/<NotInRepo>/ @dargilco @rhurey

# ServiceLabel: %Import Export %Service Attention
#/<NotInRepo>/ @madhurinms

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ import java.net.URL;
if (options == null) {
return analyzeFromBuffer(visualFeatures, imageData, null, null, null, null);
} else {
return analyzeFromBuffer(visualFeatures, imageData, options.getLanguage(), options.isGenderNeutralCaption(),
options.getSmartCropsAspectRatios(), options.getModelVersion());
return analyzeFromBuffer(visualFeatures, imageData, options.getLanguage(),
options.isGenderNeutralCaption(), options.getSmartCropsAspectRatios(), options.getModelVersion());
}
}
```
Expand Down Expand Up @@ -175,8 +175,8 @@ import java.net.URL;
if (options == null) {
return analyzeFromBuffer(visualFeatures, imageData, null, null, null, null);
} else {
return analyzeFromBuffer(visualFeatures, imageData, options.getLanguage(), options.isGenderNeutralCaption(),
options.getSmartCropsAspectRatios(), options.getModelVersion());
return analyzeFromBuffer(visualFeatures, imageData, options.getLanguage(),
options.isGenderNeutralCaption(), options.getSmartCropsAspectRatios(), options.getModelVersion());
}
}
```

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public final class ImageAnalysisClient {
* <strong>Request Body Schema</strong>
* </p>
* <pre>{@code
* BinaryData
* {
* url: String (Required)
* }
* }</pre>
* <p>
* <strong>Response Body Schema</strong>
Expand Down Expand Up @@ -220,9 +222,91 @@ public final class ImageAnalysisClient {
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
Response<BinaryData> analyzeFromBufferWithResponse(List<String> visualFeatures, BinaryData imageContent,
Response<BinaryData> analyzeFromUrlWithResponse(List<String> visualFeatures, BinaryData imageContent,
RequestOptions requestOptions) {
return this.serviceClient.analyzeFromBufferWithResponse(visualFeatures, imageContent, requestOptions);
return this.serviceClient.analyzeFromUrlWithResponse(visualFeatures, imageContent, requestOptions);
}

/**
* Performs a single Image Analysis operation.
*
* @param visualFeatures A list of visual features to analyze.
* Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People.
* At least one visual feature must be specified.
* @param imageContent The image to be analyzed.
* @param language The desired language for result generation (a two-letter language code).
* If this option is not specified, the default value 'en' is used (English).
* See https://aka.ms/cv-languages for a list of supported languages.
* @param genderNeutralCaption Boolean flag for enabling gender-neutral captioning for Caption and Dense Captions
* features.
* By default captions may contain gender terms (for example: 'man', 'woman', or 'boy', 'girl').
* If you set this to "true", those will be replaced with gender-neutral terms (for example: 'person' or 'child').
* @param smartCropsAspectRatios A list of aspect ratios to use for smart cropping.
* Aspect ratios are calculated by dividing the target crop width in pixels by the height in pixels.
* Supported values are between 0.75 and 1.8 (inclusive).
* If this parameter is not specified, the service will return one crop region with an aspect
* ratio it sees fit between 0.5 and 2.0 (inclusive).
* @param modelVersion The version of cloud AI-model used for analysis.
* The format is the following: 'latest' (default value) or 'YYYY-MM-DD' or 'YYYY-MM-DD-preview', where 'YYYY',
* 'MM', 'DD' are the year, month and day associated with the model.
* This is not commonly set, as the default always gives the latest AI model with recent improvements.
* If however you would like to make sure analysis results do not change over time, set this value to a specific
* model version.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return represents the outcome of an Image Analysis operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromUrl(List<VisualFeatures> visualFeatures, ImageUrl imageContent, String language,
Boolean genderNeutralCaption, List<Double> smartCropsAspectRatios, String modelVersion) {
// Generated convenience method for analyzeFromUrlWithResponse
RequestOptions requestOptions = new RequestOptions();
if (language != null) {
requestOptions.addQueryParam("language", language, false);
}
if (genderNeutralCaption != null) {
requestOptions.addQueryParam("gender-neutral-caption", String.valueOf(genderNeutralCaption), false);
}
if (smartCropsAspectRatios != null) {
requestOptions.addQueryParam("smartcrops-aspect-ratios", JacksonAdapter.createDefaultSerializerAdapter()
.serializeIterable(smartCropsAspectRatios, CollectionFormat.CSV), false);
}
if (modelVersion != null) {
requestOptions.addQueryParam("model-version", modelVersion, false);
}
return analyzeFromUrlWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()),
BinaryData.fromObject(imageContent), requestOptions).getValue().toObject(ImageAnalysisResult.class);
}

/**
* Performs a single Image Analysis operation.
*
* @param visualFeatures A list of visual features to analyze.
* Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People.
* At least one visual feature must be specified.
* @param imageContent The image to be analyzed.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return represents the outcome of an Image Analysis operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromUrl(List<VisualFeatures> visualFeatures, ImageUrl imageContent) {
// Generated convenience method for analyzeFromUrlWithResponse
RequestOptions requestOptions = new RequestOptions();
return analyzeFromUrlWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()),
BinaryData.fromObject(imageContent), requestOptions).getValue().toObject(ImageAnalysisResult.class);
}

/**
Expand Down Expand Up @@ -282,9 +366,7 @@ Response<BinaryData> analyzeFromBufferWithResponse(List<String> visualFeatures,
* <strong>Request Body Schema</strong>
* </p>
* <pre>{@code
* {
* url: String (Required)
* }
* BinaryData
* }</pre>
* <p>
* <strong>Response Body Schema</strong>
Expand Down Expand Up @@ -390,9 +472,9 @@ Response<BinaryData> analyzeFromBufferWithResponse(List<String> visualFeatures,
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
Response<BinaryData> analyzeFromUrlWithResponse(List<String> visualFeatures, BinaryData imageContent,
Response<BinaryData> analyzeFromImageDataWithResponse(List<String> visualFeatures, BinaryData imageContent,
RequestOptions requestOptions) {
return this.serviceClient.analyzeFromUrlWithResponse(visualFeatures, imageContent, requestOptions);
return this.serviceClient.analyzeFromImageDataWithResponse(visualFeatures, imageContent, requestOptions);
}

/**
Expand Down Expand Up @@ -430,9 +512,9 @@ Response<BinaryData> analyzeFromUrlWithResponse(List<String> visualFeatures, Bin
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromBuffer(List<VisualFeatures> visualFeatures, BinaryData imageContent, String language,
Boolean genderNeutralCaption, List<Double> smartCropsAspectRatios, String modelVersion) {
// Generated convenience method for analyzeFromBufferWithResponse
ImageAnalysisResult analyzeFromImageData(List<VisualFeatures> visualFeatures, BinaryData imageContent,
String language, Boolean genderNeutralCaption, List<Double> smartCropsAspectRatios, String modelVersion) {
// Generated convenience method for analyzeFromImageDataWithResponse
RequestOptions requestOptions = new RequestOptions();
if (language != null) {
requestOptions.addQueryParam("language", language, false);
Expand All @@ -447,7 +529,7 @@ ImageAnalysisResult analyzeFromBuffer(List<VisualFeatures> visualFeatures, Binar
if (modelVersion != null) {
requestOptions.addQueryParam("model-version", modelVersion, false);
}
return analyzeFromBufferWithResponse(visualFeatures.stream()
return analyzeFromImageDataWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()), imageContent,
requestOptions).getValue().toObject(ImageAnalysisResult.class);
}
Expand All @@ -469,96 +551,14 @@ ImageAnalysisResult analyzeFromBuffer(List<VisualFeatures> visualFeatures, Binar
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromBuffer(List<VisualFeatures> visualFeatures, BinaryData imageContent) {
// Generated convenience method for analyzeFromBufferWithResponse
ImageAnalysisResult analyzeFromImageData(List<VisualFeatures> visualFeatures, BinaryData imageContent) {
// Generated convenience method for analyzeFromImageDataWithResponse
RequestOptions requestOptions = new RequestOptions();
return analyzeFromBufferWithResponse(visualFeatures.stream()
return analyzeFromImageDataWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()), imageContent,
requestOptions).getValue().toObject(ImageAnalysisResult.class);
}

/**
* Performs a single Image Analysis operation.
*
* @param visualFeatures A list of visual features to analyze.
* Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People.
* At least one visual feature must be specified.
* @param imageContent The image to be analyzed.
* @param language The desired language for result generation (a two-letter language code).
* If this option is not specified, the default value 'en' is used (English).
* See https://aka.ms/cv-languages for a list of supported languages.
* @param genderNeutralCaption Boolean flag for enabling gender-neutral captioning for Caption and Dense Captions
* features.
* By default captions may contain gender terms (for example: 'man', 'woman', or 'boy', 'girl').
* If you set this to "true", those will be replaced with gender-neutral terms (for example: 'person' or 'child').
* @param smartCropsAspectRatios A list of aspect ratios to use for smart cropping.
* Aspect ratios are calculated by dividing the target crop width in pixels by the height in pixels.
* Supported values are between 0.75 and 1.8 (inclusive).
* If this parameter is not specified, the service will return one crop region with an aspect
* ratio it sees fit between 0.5 and 2.0 (inclusive).
* @param modelVersion The version of cloud AI-model used for analysis.
* The format is the following: 'latest' (default value) or 'YYYY-MM-DD' or 'YYYY-MM-DD-preview', where 'YYYY',
* 'MM', 'DD' are the year, month and day associated with the model.
* This is not commonly set, as the default always gives the latest AI model with recent improvements.
* If however you would like to make sure analysis results do not change over time, set this value to a specific
* model version.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return represents the outcome of an Image Analysis operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromUrl(List<VisualFeatures> visualFeatures, ImageUrl imageContent, String language,
Boolean genderNeutralCaption, List<Double> smartCropsAspectRatios, String modelVersion) {
// Generated convenience method for analyzeFromUrlWithResponse
RequestOptions requestOptions = new RequestOptions();
if (language != null) {
requestOptions.addQueryParam("language", language, false);
}
if (genderNeutralCaption != null) {
requestOptions.addQueryParam("gender-neutral-caption", String.valueOf(genderNeutralCaption), false);
}
if (smartCropsAspectRatios != null) {
requestOptions.addQueryParam("smartcrops-aspect-ratios", JacksonAdapter.createDefaultSerializerAdapter()
.serializeIterable(smartCropsAspectRatios, CollectionFormat.CSV), false);
}
if (modelVersion != null) {
requestOptions.addQueryParam("model-version", modelVersion, false);
}
return analyzeFromUrlWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()),
BinaryData.fromObject(imageContent), requestOptions).getValue().toObject(ImageAnalysisResult.class);
}

/**
* Performs a single Image Analysis operation.
*
* @param visualFeatures A list of visual features to analyze.
* Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People.
* At least one visual feature must be specified.
* @param imageContent The image to be analyzed.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return represents the outcome of an Image Analysis operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
ImageAnalysisResult analyzeFromUrl(List<VisualFeatures> visualFeatures, ImageUrl imageContent) {
// Generated convenience method for analyzeFromUrlWithResponse
RequestOptions requestOptions = new RequestOptions();
return analyzeFromUrlWithResponse(visualFeatures.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, "")).collect(Collectors.toList()),
BinaryData.fromObject(imageContent), requestOptions).getValue().toObject(ImageAnalysisResult.class);
}

/**
* Performs a single Image Analysis operation on a give image URL.
*
Expand Down Expand Up @@ -664,10 +664,10 @@ public ImageAnalysisResult analyze(URL imageUrl, List<VisualFeatures> visualFeat
public ImageAnalysisResult analyze(BinaryData imageData, List<VisualFeatures> visualFeatures,
ImageAnalysisOptions options) {
if (options == null) {
return analyzeFromBuffer(visualFeatures, imageData, null, null, null, null);
return analyzeFromImageData(visualFeatures, imageData, null, null, null, null);
} else {
return analyzeFromBuffer(visualFeatures, imageData, options.getLanguage(), options.isGenderNeutralCaption(),
options.getSmartCropsAspectRatios(), options.getModelVersion());
return analyzeFromImageData(visualFeatures, imageData, options.getLanguage(),
options.isGenderNeutralCaption(), options.getSmartCropsAspectRatios(), options.getModelVersion());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

/**
* A builder for creating a new instance of the ImageAnalysisClient type.
*
*
* <!-- src_embed com.azure.ai.vision.imageanalysis.sync-client -->
* <pre>
* &#47;&#47;
Expand All @@ -66,7 +66,7 @@
* .buildAsyncClient&#40;&#41;;
* </pre>
* <!-- end com.azure.ai.vision.imageanalysis.async-client -->
*
*
*/
@ServiceClientBuilder(serviceClients = { ImageAnalysisClient.class, ImageAnalysisAsyncClient.class })
public final class ImageAnalysisClientBuilder
Expand Down
Loading

0 comments on commit 8e29482

Please sign in to comment.