Skip to content

Image-Position-Editing is a image processing tool for generating segmented masks, changing object positions, and removing objects from images with text prompt

Notifications You must be signed in to change notification settings

Luckygyana/Image-Position-Editing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image-Position-Editing

Table of Contents

Introduction

Image-Position-Editing is a versatile image processing tool that allows users to perform various tasks on images, such as generating segmented masks, changing the position of segmented objects, and removing objects. This tool leverages advanced segmentation models to achieve these tasks efficiently.


Try out in Google Colab

Requirements

  • Python 3.6+
  • src package including Image-Position-Editing
  • Additional dependencies as specified in requirements.txt

Installation

  1. Clone the repository:

    git clone https://github.com/luckygyana/Image-Position-Editing.git
    cd ImageEditor
  2. Install the required dependencies:

    pip install -r requirements.txt
    python -m pip install -r lama/requirements.txt 
  3. Download the model checkpoints provided in big-lama, and put them into ./pretrained_models. For simplicity, you can also go here, directly download pretrained_models, put the directory into ./ and get ./pretrained_models.

Usage

The Image-Position-Editing script can be used from the command line to perform various image processing tasks. Below are the common arguments and task-specific arguments.

Common Arguments

  • --image: Path to the input image (required).
  • --class: Class of the object to be segmented (required).
  • --output: Path to the output image (required).

Tasks

Task 1: Generate Segmented Mask on the Object

Generates a segmented mask over the specified object in the image.

python script.py --image path/to/image.jpg --class "object_class" --output path/to/output.jpg task1

Task 2: Change Position of the Segmented Object

Changes the position of the segmented object by the specified number of pixels in the x and y directions.

python script.py --image path/to/image.jpg --class "object_class" --output path/to/output.jpg task2 --x shift_x --y shift_y
  • --x: Number of pixels to shift in the x direction (required).
  • --y: Number of pixels to shift in the y direction (required).

Task 3: Remove the Object

Removes the specified object from the image.

python script.py --image path/to/image.jpg --class "object_class" --output path/to/output.jpg task3

Examples

Example 1: Generate Segmented Mask

python script.py --image wall_hanging.jpg --class "wall hanging" --output masked_wall_hanging.jpg task1

Input and Output:

Input Image Output Image
Input Image Output Image

Example 2: Change Object Position

python script.py --image wall_hanging.jpg --class "wall hanging" --output moved_wall_hanging".jpg task2 --x 500 --y 100

Input and Output:

Input Image Output Image
Input Image Output Image

Example 3: Remove Object

python script.py --image ../example/wall_hanging.jpg --class "wall hanging" --output no_wall_hanging.jpg task3

Input and Output:

Input Image Output Image
Input Image Output Image

Directory Structure

Image-Position-Editing/
├── lama/
│   ├── configs/
│   │   └── prediction/
│   │       └── default.yaml
│   └── pretrained-models/
│       └── big-lama
|   └── requirements.txt
├── src.py
├── run.py
├── requirements.txt
└── README.md

Configuration Files

The lama directory contains the necessary configuration files and pre-trained models for performing the image editing tasks. The default configuration file for predictions is located at lama/configs/prediction/default.yaml.

Acknowledgments


For any further questions or support, please open an issue on the GitHub repository.

About

Image-Position-Editing is a image processing tool for generating segmented masks, changing object positions, and removing objects from images with text prompt

Topics

Resources

Stars

Watchers

Forks