Skip to content

This repository contains testing source code for artwork segmentation. I developed a deep learning pipeline to segment artwork, designs, and logos from backgrounds such as walls and surfaces. This pipeline works with any orientation of the artwork.

Notifications You must be signed in to change notification settings

sanbuddhacharyas/artwork_segmentation

Repository files navigation

Art Segmentation

Image 1 Image 2 Image 3

Image 1 Image 2 Image 3

Image 1 Image 2 Image 3

Image 1 Image 2 Image 3

Image 1 Image 2 Image 3

Download weights from Google Drive

    gdown --id 1EDUARyROWS1yUbqTcZ0AhJ7K-31M9MZk
    unzip weight.zip

Manually from bash https://drive.google.com/file/d/1EDUARyROWS1yUbqTcZ0AhJ7K-31M9MZk/view?usp=drive_link

Install Required Dependencies

Create Virtual Environment

    conda create --name artdetector python=3.8
    conda activate artdetector

Install Dependencies

    pip install -r requirements.txt

Run Flask program

    python application.py

Run Browser to test segmentation

 http://127.0.0.1:5000

Choose your image and click the Upload button
Wait until you get the segmented output

Click the ReTake Button to test new images

API

URL: http://127.0.0.1:5000/detectart

OPEN POSTMAN: POST body

    {
        "image":"<base64 image>"
    }

Run Docker

    docker build -t <your_tag> .
    docker container run -p 5001:5000 <your_tag>

Deploying Art Detector AI Engine in Elastic BeanStalk

Make .zip folder with following hierachy

Flask app.
│   application.py
│   src
│   README.md
│   requirements.txt
│
├───.ebextensions
│       packages.config
│       python.config
│
├───.platform
│   └───nginx
│       └───conf.d
│               upload_size.conf
│
├───templates
│       index.html
│       output.html
|───weights

NOTE: The name of your main flask app must be application.py

Install required packages in Elastic BeanStalk Environment

  1. Create a folder name .ebextensions
  2. Create file packages.config name and paste the following lines
commands:
    install_mesa:
        command: yum install mesa-libGL -y

The above command install libGL library which is required for OpenCV and rembg

  1. Create file python.config
option_settings:
  "aws:elasticbeanstalk:container:python":
    WSGIPath: application:application
  1. Create folder name .platform/nginx/conf.d and file .platform/nginx/conf.d/upload_size.conf
client_max_body_size 20M;
proxy_read_timeout 3000;
proxy_connect_timeout 3000;
proxy_send_timeout 3000;

client_max_body_size: proxy_read_timeout: proxy_connect_timeout: proxy_send_timeout:

Create Elastic BeanStalk Application

  1. Open Elastic BeanStalk
  2. Click Create environment Fill Following Information:

Application Information Application name: Artdetector

Platform platform: Python platform branch: Python 3.8 platform version: 3.5.3

Application code Upload your code Version label: ver-1 Local file: Upload application (Choose File)

Presents: Single instance

Click Next

  1. Service role:
    • Create and use new service role

EC2 key pair: - Select your keys

EC2 instance profile: -

Create role with name: aws-elasticbeanstalk-ec2-role Goto: IAM > Roles > Create role Add Permission details:

    AWSElasticBeanstalkEnhancedHealth
    AdministratorAccess-AWSElasticBeanstalk
    AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy

Click Next

  1. Configure instance traffic and scaling

Instance settings: Public IP address: tick: Activated

Click Next

Add EC2 Security groups: Enable Port 5000 - 5005

Auto scaling group: Select your environment type: Single Instance or Load Balance

Select instance t3.x2large, t3.xlarge

Click Next

  1. Configure updates, monitoring, and logging Rolling updates and deployments: Command timeout: 3500

Click Next

  1. Submit

About

This repository contains testing source code for artwork segmentation. I developed a deep learning pipeline to segment artwork, designs, and logos from backgrounds such as walls and surfaces. This pipeline works with any orientation of the artwork.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published