Skip to main content

Mini photoshop tool

Project description

Mini Photoshop Tool

Introduction

Major Features

  • Free and open source
  • Using SOTA models: U2Net and LaMa
  • Support 2 running option: library or web app
  • Support CPU and GPU (default: CPU)
  • Support: Background Removal and Object Removal (web app usage)

TODO

  • [] Support batch processing (for library usage)
  • [] Post processing for image smoothing
  • [] Optimize processing time with large image

Installation

pip install mini-photoshop

Library Usage

import cv2
import warnings
warnings.simplefilter('ignore')
from matplotlib import pyplot as plt

from mini_photoshop.model import InpaintModel, SalientModel


device = "cpu"
img_path = "PASTE IMAGE PATH HERE"
# model_name can be "u2net_lite", "u2net", "u2net_human_seg"
salient_model = SalientModel(model_name='u2net_lite', device=device)
inpaint_model = InpaintModel(device=device)

original_image = cv2.imread(img_path)
original_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2RGB)
original_mask = salient_model(original_image)

# Create a copy of the image and set all background values to 255 (white)
bg_removed_result = original_image.copy()
bg_removed_result[original_mask == 0] = 255

inpaint_result = inpaint_model(original_image, original_mask*255)
inpaint_result = cv2.cvtColor(inpaint_result, cv2.COLOR_BGR2RGB)

fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(20, 7))
ax[0].imshow(original_image)
ax[1].imshow(bg_removed_result)
ax[2].imshow(inpaint_result)
for a in ax:
    a.axis("off")
plt.show()

web app usage

Web App Usage

Run command

mini-photoshop

and then go to: http://localhost:8501/

web app usage

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mini-photoshop-0.1.1.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

mini_photoshop-0.1.1-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page