devskale
commited on
Commit
Β·
4068228
1
Parent(s):
9dbb877
readme
Browse files
README.md
CHANGED
|
@@ -9,122 +9,123 @@ app_file: gradio_imager.py
|
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
-
#
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
## Features
|
| 17 |
|
| 18 |
-
- **Background Removal**: Automatically
|
| 19 |
-
- **
|
| 20 |
-
- **Resizing**:
|
| 21 |
-
- **Padding**:
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
## Installation
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
You can install the required packages using pip:
|
| 30 |
-
|
| 31 |
-
```sh
|
| 32 |
-
pip install Pillow rembg
|
| 33 |
```
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
```
|
| 40 |
python imager.py -b -c -r 800x600 -p 10
|
| 41 |
```
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
- `-
|
| 46 |
-
- `-
|
| 47 |
-
- `-
|
| 48 |
-
- `-
|
| 49 |
-
- `-bg, --background BACKGROUND`: Add a background to the image. Accepts color names, hex codes, or paths to image files.
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 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 |
-
|
| 61 |
-
|
| 62 |
-
|
| 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 |
-
|
| 72 |
|
| 73 |
-
```
|
| 74 |
-
python
|
| 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 |
-
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 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 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 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
|