Giter VIP home page Giter VIP logo

comfyui-autotrimbg's Introduction

ComfyUI-AutoCropBgTrim

ComfyUI-AutoCropBgTrim is a powerful tool designed to automatically clean up the background of your images. This tool trims unnecessary spaces and pixels, leaving only the main subject of the image. It generates both a mask and an image output, making it easy to focus on the essential elements. Perfect for enhancing your photos and preparing them for professional use.

Demo

Features

  • Automatically trims backgrounds.
  • Leaves only the main subject.
  • Generates a mask and an image output.
  • Adjustable padding for cropping.

Installation

To install ComfyUI-AutoCropBgTrim, clone the repository and install the dependencies:

git clone https://github.com/yourusername/ComfyUI-AutoCropBgTrim.git
cd ComfyUI-AutoCropBgTrim
pip install -r requirements.txt

Usage

Here is an example of how to use ComfyUI-AutoCropBgTrim in your project:

import torch
from PIL import Image
from ComfyUI-AutoCropBgTrim import RonLayersTrimBgUltraV2

# Load your image and mask
image = torch.load('path/to/image.pt')
mask = torch.load('path/to/mask.pt')

# Initialize the class
cropper = RonLayersTrimBgUltraV2()

# Set the padding (optional)
padding = 10

# Run the cropping function
cropped_image, cropped_mask, crop_box, box_preview = cropper.run(image, mask, padding)

# Save or process the results
cropped_image.save('path/to/cropped_image.png')
cropped_mask.save('path/to/cropped_mask.png')
box_preview.save('path/to/box_preview.png')

Class and Methods

The main class provided by ComfyUI-AutoCropBgTrim is RonLayersTrimBgUltraV2. Below are the main methods and their descriptions:

RonLayersTrimBgUltraV2

  • __init__: Initializes the class with default values for input and output images, masks, and cropping boxes.
  • INPUT_TYPES: Defines the input types for the class methods, including the image, mask, and padding.
  • trim_and_crop_by_mask(image, mask, padding): Trims and crops the image based on the mask, with optional padding.
  • run(image, mask, padding): Runs the trim_and_crop_by_mask method and stores the results.

Contributing

If you want to contribute to ComfyUI-AutoCropBgTrim, please fork the repository and create a pull request with your changes.

License

ComfyUI-AutoCropBgTrim is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any questions or feedback, please open an issue on GitHub or contact the repository owner.

Enjoy using ComfyUI-AutoCropBgTrim for your image processing needs!

comfyui-autotrimbg's People

Contributors

fexploit avatar haohaocreates avatar

Stargazers

 avatar VALADI K JAGANATHAN avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.