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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file mini-photoshop-0.1.1.tar.gz.

File metadata

  • Download URL: mini-photoshop-0.1.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for mini-photoshop-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2d31ba8c92afda7b227762c94821fa00cfba0e994d924546c9cfbb8de701c61b
MD5 f94883d1a0477c03de7342af2c318659
BLAKE2b-256 183374abe9ab19017593dd639435827923ef72b513853b6e4b7b070588b8659a

See more details on using hashes here.

File details

Details for the file mini_photoshop-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_photoshop-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1c3877c09426d28029c63a2c4ff112c6bc56ea671b886bff634e90051857cd6
MD5 44ac250a6a113741c33da2db6af499d3
BLAKE2b-256 a7547cf91d6168852c62047f89dd2ef3d1b99f2be32cbee245560117dc4bd525

See more details on using hashes here.

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