awslabs / aws-ai-solution-kit

Machine Learning APIs for common use cases, include: General OCR (Simplified/Traditional Chinese), Custom OCR, Image Similarity, Object Recognition, Face Detection, Face Comparison, Human Image Segmentation, Human Attribute Recognition, Pornography Detection, Image Super Resolution, Text Similarity, Car License Plate, etc.
Apache License 2.0
150 stars 24 forks source link

Stack fails on PornographyDetection installation #95

Closed gotters closed 1 year ago

gotters commented 1 year ago

Expected Behavior

Template should create stack

Current Behavior

Template fails

Possible Solution

How to reproduce (for bugs)

Import template and create stack with PornographyDetection | yes-lambda enabled

Stack creation fails with the following error, no other info provided. Embedded stack arn:aws:cloudformation:us-east-1:948320724766:stack/AIImageDetector-PornographyDetectionNestedStackPornographyDetectionNestedStackResource-36PDX2AQZ7GR/b095a010-8c33-11ed-8a72-1232682a975b was not successfully created: The following resource(s) failed to create: [pornographydetectionpornographydetectionAppDCBBB4C1].

NingLu commented 1 year ago

Hi @gotters

I can't reproduce it in us-east-1, would you provide more details such as the CFN template url, the parameters you set?

and is there any more error messages? you will see the error by scrolling down in CloudFormation event tab

NingLu commented 1 year ago
Screen Shot 2023-01-05 at 09 17 34
gotters commented 1 year ago

I launched the template from your readme as per your launch link: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=AI-Solution-Kit&templateURL=https://aws-gcr-solutions.s3.amazonaws.com/Aws-gcr-ai-solution-kit/v1.3.0/AI-Solution-Kit.template

My parameters are the same as yours: image

Could it have something to do with this? Do I need some specific Role or IAM Resource setup first? image

There is no useful or helpful error info. It fails on this below...and then rolls back. No other errors. How can I find out more regarding what is failing? image

Thanks for your help

gotters commented 1 year ago

I tried again without rollback and this time got more details in the error.

image

These are my memory settings in lambda, surely this is good enough? image

How do I resolve this? Thanks

yanbasic commented 1 year ago

Hi @gotters, thanks for your reply, I assume your account have the lambda function memory limitation, it cannot create a larger memory function than 3008, could you please do a simple test, just creating a python 3.9 lambda function in your account with memory size like 4096 to see it can be created, if not, please request to increase the memory limit of the AWS Lambda service by this guide.

gotters commented 1 year ago

Thanks for the reply

But my memory settings in AWS Lambda are set to 10,290 MB (as per screenshot). I don't even have the ability to request more - i think that is max. [image: image.png] How do I create a lamba function with a specific memory size? I can create a 3.9 Python function but no option to specify memory?

Thanks

On Thu, Jan 5, 2023 at 10:11 AM Mike Yan @.***> wrote:

Hi @gotters https://github.com/gotters, thanks for your reply, I assume your account have the lambda function memory limitation, it cannot create a larger memory function than 3008, could you please do a simple test, just creating a python 3.9 lambda function in your account with memory size like 4096 to see it can be created, if not, please request to increase the memory limit of the AWS Lambda service by this guide https://awslabs.github.io/aws-ai-solution-kit/en/faq/#3-when-deploying-the-solution-i-encountered-resource-handler-returned-message-memorysize-value-failed-to-satisfy-constraint-member-must-have-value-less-than-or-equal-to-3008-how-to-resolve-it .

— Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-ai-solution-kit/issues/95#issuecomment-1371901993, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRXRDAOLQD6DWEZA64DV33WQZ64XANCNFSM6AAAAAATQZYD6A . You are receiving this because you were mentioned.Message ID: @.***>

yanbasic commented 1 year ago

Hi @gotters, once the Lambda function has been created, the memory can be updated in the General Configuration tag, in the Memory, default is 128MB, the value can be set to 10240 MB for test.

Thanks,

iShot_2023-01-06_09 04 13
gotters commented 1 year ago

Thanks you're correct. I get the same error trying to set memory to 4096 MB. But the resources show my max is 10240MB - do you know why it would be doing this?

On Fri, Jan 6, 2023 at 3:09 AM Mike Yan @.***> wrote:

Hi @gotters https://github.com/gotters, once the Lambda function has been created, the memory can be updated in the General Configuration tag, in the Memory, default is 128MB, the value can be set to 10240 MB for test.

Thanks, [image: iShot_2023-01-06_09 04 13] https://user-images.githubusercontent.com/1256820/210908934-10d3fbb1-6230-4036-8e57-3f2dee65b875.png

— Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-ai-solution-kit/issues/95#issuecomment-1373003664, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRXRDC36WSL4TT5INVF3DDWQ5WEPANCNFSM6AAAAAATQZYD6A . You are receiving this because you were mentioned.Message ID: @.***>

yanbasic commented 1 year ago

Hi @gotters, thanks for your confirmation, it seems you have to request to increase the memory limit in your account, if you just want to deploy the PornographyDetection feature, you can also reduce the memory to 3008 in the source code here: https://github.com/awslabs/aws-ai-solution-kit/blob/main/src/api-deployment/ai-solution-kit-stack.ts#L412 and deploy the feature by CDK deploy, it might be a bit slowly than the default memory size.

gotters commented 1 year ago

Ok thank you. For some reason I don't have the ability to request a quota increase. I dont know why. In the end I deployed it to sageMaker - is there a significant difference?

Unfortunately after some testing I dont think its going to help me. I have a difficult use case scenario where I need images of screenshots that have been blurred to be analyzed. I think given that its a screenshot - which can contain multiple parts and not just one image - and the fact that it is slightly blurred - is making the detection algorithm ineffective.

Can you confirm? Thanks Moshe

On Mon, Jan 9, 2023 at 2:15 PM Mike Yan @.***> wrote:

Hi @gotters https://github.com/gotters, thanks for your confirmation, it seems you have to request to increase the memory limit in your account, if you just want to deploy the PornographyDetection feature, you can also reduce the memory to 3008 in the source code here: https://github.com/awslabs/aws-ai-solution-kit/blob/main/src/api-deployment/ai-solution-kit-stack.ts#L412 and deploy the feature by CDK deploy, it might be a bit slowly than the default memory size.

— Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-ai-solution-kit/issues/95#issuecomment-1375540793, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRXRDFK5F5BB4PNNKDC33LWRP6PRANCNFSM6AAAAAATQZYD6A . You are receiving this because you were mentioned.Message ID: @.***>

yanbasic commented 1 year ago

Hi @gotters, the Lambda and SageMaker models are the same result, the SageMaker based feature will create a SageMaker instance, you can undeploy the feature after you test it to avoid additional cost in your account. The model for pornography detection is trained by common sample dataset, I'm afraid it cannot detect the 'blurred' images, did you try to detect only one image to see the result is correct?

gotters commented 1 year ago

Thanks for the info.

I thought i would try the enhance image resolution feature, followed by the pornography detection - do you think that would help? I deleted my previous stack which had the porn detector in sage maker and tried creating a new one with both in sage maker but now its failing completely with the errors below. But I cant see those resources?

Resource handler returned message: "Resource of type 'AWS::ECR::Repository' with identifier 'ai-solution-kit-super-resolution-sagemaker' already exists." (RequestToken: 6268e451-0e98-58b6-9211-a17131e59435, HandlerErrorCode: AlreadyExists)

Resource handler returned message: "Resource of type 'AWS::ECR::Repository' with identifier 'ai-solution-kit-pornography-detection-sagemaker' already exists." (RequestToken: 8b01d46d-7787-466c-f042-77438c6a03af, HandlerErrorCode: AlreadyExists)

On Tue, Jan 10, 2023 at 11:14 AM Mike Yan @.***> wrote:

Hi @gotters https://github.com/gotters, the Lambda and SageMaker models are the same result, the SageMaker based feature will create a SageMaker instance, you can undeploy the feature after you test it to avoid additional cost in your account. The model for pornography detection is trained by common sample dataset, I'm afraid it cannot detect the 'blurred' images, did you try to detect only one image to see the result is correct?

— Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-ai-solution-kit/issues/95#issuecomment-1376949144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRXRDH4676AFHDDBESDCP3WRUSAVANCNFSM6AAAAAATQZYD6A . You are receiving this because you were mentioned.Message ID: @.***>

yanbasic commented 1 year ago

I'm afraid the Super Resolution might not help for your case, for the above error you can open AWS ECR web console and delete the related repositories before deploy the new CloudFormation stack. What's the detection result for the Pornography Detection API?