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.
- Python 3.6+
src
package includingImage-Position-Editing
- Additional dependencies as specified in
requirements.txt
-
Clone the repository:
git clone https://github.com/luckygyana/Image-Position-Editing.git cd ImageEditor
-
Install the required dependencies:
pip install -r requirements.txt python -m pip install -r lama/requirements.txt
-
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
.
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.
--image
: Path to the input image (required).--class
: Class of the object to be segmented (required).--output
: Path to the output image (required).
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
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).
Removes the specified object from the image.
python script.py --image path/to/image.jpg --class "object_class" --output path/to/output.jpg task3
python script.py --image wall_hanging.jpg --class "wall hanging" --output masked_wall_hanging.jpg task1
Input and Output:
Input Image | Output Image |
---|---|
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 |
---|---|
python script.py --image ../example/wall_hanging.jpg --class "wall hanging" --output no_wall_hanging.jpg task3
Input and Output:
Input Image | Output Image |
---|---|
Image-Position-Editing/
├── lama/
│ ├── configs/
│ │ └── prediction/
│ │ └── default.yaml
│ └── pretrained-models/
│ └── big-lama
| └── requirements.txt
├── src.py
├── run.py
├── requirements.txt
└── README.md
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
.
- Segmentation code and models if form CSAILVision.
- Lama Model from LaMa
- LPIPS metric is from richzhang
- SSIM is from Po-Hsun-Su
- FID is from mseitzer
- Inpaint-Anything
- GroundingDINO
- Segment-Anything
- Lightning AI
For any further questions or support, please open an issue on the GitHub repository.