devskale commited on
Commit
4068228
Β·
1 Parent(s): 9dbb877
Files changed (1) hide show
  1. README.md +81 -80
README.md CHANGED
@@ -9,122 +9,123 @@ app_file: gradio_imager.py
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
- # Product IMAGER ___ Image Processing Script
13
 
14
- This Python script offers a versatile image processing toolkit, allowing for operations such as background removal, autocropping, resizing, and adding padding to images. It's designed to process images in bulk, making it an ideal solution for preparing images for web use or personal projects.
15
 
16
- ## Features
17
 
18
- - **Background Removal**: Automatically removes the background from images.
19
- - **Autocropping**: Crops images to remove unnecessary transparent space.
20
- - **Resizing**: Resizes images to specified dimensions, maintaining aspect ratio.ssh -
21
- - **Padding**: Adds padding around images, ensuring the final image size matches specified dimensions.
 
 
 
22
 
23
- ## Installation
24
 
25
- To run this script, you'll need Python installed on your system along with the following packages:
26
- - Pillow
27
- - rembg
28
-
29
- You can install the required packages using pip:
30
-
31
- ```sh
32
- pip install Pillow rembg
33
  ```
34
 
35
- # CLI Usage imager.py
36
 
37
- Place the images you want to process in the ./input directory. The CLI command is intended for bulk processing. Run the script with desired options:
38
 
39
- ```sh
40
  python imager.py -b -c -r 800x600 -p 10
41
  ```
42
 
43
- ## Command-Line Arguments
44
-
45
- - `-b, --background_removal`: Enable background removal.
46
- - `-c, --crop`: Enable autocropping.
47
- - `-r, --resize AxB`: Resize the image to fit within AxB pixels, maintaining aspect ratio.
48
- - `-p, --padding PIXELS`: Add PIXELS number of padding around the image. The final image size stays as specified in `-r AxB`.
49
- - `-bg, --background BACKGROUND`: Add a background to the image. Accepts color names, hex codes, or paths to image files.
50
 
51
- ## Example
52
- To process images by removing the background, autocropping, resizing to 800x600 pixels, and adding 10 pixels of padding:
53
-
54
- ```sh
55
  python imager.py -b -c -r 320x280 -p 10
56
- ```
57
-
58
- This command processes all images in the ./input directory and saves the processed images to the ./output directory.
59
 
60
- Super Mario and Fujicamera automatically converted by imager.py: bg_removed, cropped and skaled to 320x280.
61
-
62
- <img src="data/examples/supermario.png" alt="alt text" width="200" style="border: 1px solid white;">
63
- <img src="data/examples/supermario_b_c320x280.png" alt="alt text" width="200" style="border: 1px solid white;">
64
-
65
- <img src="data/examples/depositphotos_520707962-stock-photo-fujifilm-s10-body-black-fujifilm.jpg" alt="alt text" width="200" style="border: 1px solid white;">
66
- <img src="data/examples/depositphotos_520707962-stock-photo-fujifilm-s10-body-black-fujifilm_b_c320x280.png" alt="alt text" width="200" style="border: 1px solid white;">
67
 
68
-
69
- ### Adding a background
70
 
71
- Let's add a blue and a green and blue background.
72
 
73
- ```sh
74
- python imager.py -b -c -r 320x280 -p 10 -bg green
75
  ```
76
- <img src="data/examples/batman_b_c_320x280_bg.png" alt="alt text" width="200" style="border: 1px solid white;">
77
- <img src="data/examples/supermario2_b_c_320x280_bg.png" alt="alt text" width="200" style="border: 1px solid white;">
78
 
 
 
 
 
 
 
 
 
79
 
80
- ## Background Colors
 
 
81
 
82
- Grayscale Monochrome Color Palette: This palette consists of different shades of gray, from light to dark, creating a simple yet effective look. The hex codes are:
83
 
 
84
  | Color Name | Hex Code |
85
  |----------------|----------|
86
- | Light Gray | #D1D1D3 |
87
- | Lavender Gray | #C6C6C7 |
88
- | Silver Foil | #AFAFB0 |
89
- | Quick Silver | #A4A4A5 |
90
- | Spanish Gray | #999999 |
91
-
92
- Feminine Soft Neutrals: This palette features warm and cozy tones, such as sand, orange, and pink, creating an inviting atmosphere. The hex codes are:
93
 
 
94
  | Color Name | Hex Code |
95
  |---------------|----------|
96
- | Alabaster | #F4EEE1 |
97
- | Dark Vanilla | #C4BDAC |
98
- | Dust Storm | #EBCFC4 |
99
- | Pale Silver | #D3C4BE |
100
- | Desert Sand | #E9CCB1 |
101
-
102
-
103
- Neutral Brown Color Palette: This palette offers a rich range of brown tones, from deep and dark to light and delicate, creating a sense of stability and warmth. The hex codes are:
104
 
 
105
  | Color Name | Hex Code |
106
  |-----------------|----------|
107
- | CafΓ© Noir | #4E3829 |
108
- | Coffee | #6B513E |
109
- | Beaver | #8E7766 |
110
- | Khaki | #B09C8D |
111
- | Champagne Pink | #E6D7CE |
112
 
113
- # Gradio App gradio_imager.py
114
 
115
- start the gradio app with the below command. the app can handle only one image at a time.
116
- ```sh
117
- python gradio_imager.py
118
- ```
119
 
120
- ![gradio app](data/gradioimager2.png)
121
 
122
- # License
123
- This project is open-source and available under the MIT License.
 
 
 
 
124
 
125
- ## Contributing
126
 
127
- Contributions to improve the script or add new features are welcome. Please feel free to fork the repository and submit pull requests.
128
 
 
 
 
129
 
130
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
+ # IMAGER - Advanced Image Processing Tool πŸ–ΌοΈ
13
 
14
+ IMAGER is a versatile image processing toolkit that offers both a CLI interface for bulk processing and a user-friendly Gradio web interface. It supports various image manipulation features including background removal, resizing, cropping, and background color adjustment.
15
 
16
+ ## Features πŸš€
17
 
18
+ - **Background Removal**: Automatically remove image backgrounds using the `rembg` library
19
+ - **Smart Cropping**: Autocrop images based on content
20
+ - **Flexible Resizing**: Resize images while maintaining aspect ratio
21
+ - **Padding Control**: Add customizable padding around images
22
+ - **Background Customization**: Set custom background colors or use color names
23
+ - **Preset Settings**: Choose from predefined configurations (S/M/L, light/dark themes)
24
+ - **Dual Interface**: Use either CLI for batch processing or Gradio web interface for single images
25
 
26
+ ## Installation πŸ”§
27
 
28
+ ```bash
29
+ # Install required packages
30
+ pip install Pillow rembg onnxruntime gradio
 
 
 
 
 
31
  ```
32
 
33
+ ## CLI Usage (imager.py) πŸ’»
34
 
35
+ Perfect for bulk processing images. Place images in the `./input` directory and run:
36
 
37
+ ```bash
38
  python imager.py -b -c -r 800x600 -p 10
39
  ```
40
 
41
+ ### Command-Line Arguments
42
+ - `-b, --background_removal`: Enable background removal
43
+ - `-c, --crop`: Enable autocropping
44
+ - `-r, --resize AxB`: Resize to AxB pixels (maintains aspect ratio)
45
+ - `-p, --padding PIXELS`: Add padding around the image
46
+ - `-bg, --background BACKGROUND`: Add background (color name, hex code, or image path)
 
47
 
48
+ ### CLI Example
49
+ ```bash
50
+ # Process images with background removal, crop, and resize to 320x280
 
51
  python imager.py -b -c -r 320x280 -p 10
 
 
 
52
 
53
+ # Add a green background
54
+ python imager.py -b -c -r 320x280 -p 10 -bg green
55
+ ```
 
 
 
 
56
 
57
+ ## Gradio Web Interface (gradio_imager.py) 🌐
 
58
 
59
+ For processing single images with real-time preview:
60
 
61
+ ```bash
62
+ python gradio_imager.py
63
  ```
 
 
64
 
65
+ ### Web Interface Features
66
+ 1. Upload an image or use example images
67
+ 2. Choose from preset settings or customize:
68
+ - Enable/disable cropping
69
+ - Toggle background removal
70
+ - Set custom dimensions (e.g., "480x480")
71
+ - Adjust padding (0-200 pixels)
72
+ - Choose background color
73
 
74
+ ### Standard Settings βš™οΈ
75
+ - **Light Theme**: S (240x240), M (480x480), L (960x960)
76
+ - **Dark Theme**: Same sizes with dark background (#2A373D)
77
 
78
+ ## Background Color Palettes 🎨
79
 
80
+ ### Grayscale Monochrome
81
  | Color Name | Hex Code |
82
  |----------------|----------|
83
+ | Light Gray | #D1D1D3 |
84
+ | Lavender Gray | #C6C6C7 |
85
+ | Silver Foil | #AFAFB0 |
86
+ | Quick Silver | #A4A4A5 |
87
+ | Spanish Gray | #999999 |
 
 
88
 
89
+ ### Feminine Soft Neutrals
90
  | Color Name | Hex Code |
91
  |---------------|----------|
92
+ | Alabaster | #F4EEE1 |
93
+ | Dark Vanilla | #C4BDAC |
94
+ | Dust Storm | #EBCFC4 |
95
+ | Pale Silver | #D3C4BE |
96
+ | Desert Sand | #E9CCB1 |
 
 
 
97
 
98
+ ### Neutral Brown
99
  | Color Name | Hex Code |
100
  |-----------------|----------|
101
+ | CafΓ© Noir | #4E3829 |
102
+ | Coffee | #6B513E |
103
+ | Beaver | #8E7766 |
104
+ | Khaki | #B09C8D |
105
+ | Champagne Pink | #E6D7CE |
106
 
107
+ ## Code Structure πŸ“
108
 
109
+ - `imager.py`: CLI interface for batch processing
110
+ - `gradio_imager.py`: Gradio web interface
111
+ - `image_processor.py`: Core image processing functions
112
+ - `/data/examples/`: Example images for testing
113
 
114
+ ## Technical Stack πŸ› οΈ
115
 
116
+ - `Gradio` for web interface
117
+ - `PIL` for image processing
118
+ - `rembg` for background removal
119
+ - `onnxruntime` for ML operations
120
+
121
+ ## Contributing 🀝
122
 
123
+ Contributions are welcome! Feel free to fork the repository and submit pull requests.
124
 
125
+ ## License πŸ“œ
126
 
127
+ This project is open-source and available under the MIT License.
128
+
129
+ ---
130
 
131
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference