Skip to content

Commit 72097ee

Browse files
Add files via upload
1 parent 60e9f45 commit 72097ee

File tree

1 file changed

+126
-37
lines changed

1 file changed

+126
-37
lines changed

README.md

Lines changed: 126 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
11
<p align="center">
22
<img src="assets/Banner.png" alt="ScaleX-CLI Banner">
3+
<!-- Make sure 'assets/Banner.png' exists in your project or update the path -->
34
</p>
45

56
# 🌟 ScaleX: AI Face Restoration & Enhancement CLI
67

78
ScaleX is a powerful command-line tool for enhancing and restoring faces in images using advanced AI. Built on the robust foundations of GFPGAN and Real-ESRGAN, ScaleX has been modernized for Python 3.12, features a user-friendly interactive CLI, and includes smarts for easier setup and smoother operation.
89

10+
<!-- Optional: Add a before/after image or a short demo GIF -->
11+
<!--
12+
<p align="center">
13+
<img src="assets/scalex_before_after_example.png" width="70%" alt="ScaleX Before and After">
14+
</p>
15+
-->
16+
917
## 🗂 Table of Contents
18+
1019
- 📖 [Introduction](#-introduction)
1120
-[Features](#-features)
1221
- 🛠️ [Installation](#️-installation)
22+
- 📋 [Prerequisites](#-prerequisites)
23+
- 🚀 [Automated Installation (Recommended)](#-automated-installation-recommended)
24+
- 🔩 [Manual Installation](#-manual-installation)
1325
- 💻 [Usage](#-usage)
26+
- ▶️ [Running ScaleX](#️-running-scalex)
27+
- ⚙️ [Key Options](#️-key-options)
1428
- 💡 [Troubleshooting](#-troubleshooting)
1529
- 🤝 [Contributing](#-contributing)
1630
- 📜 [Acknowledgments & License](#-acknowledgments--license)
1731

1832
---
1933

2034
## 📖 Introduction
35+
2136
ScaleX brings cutting-edge AI face restoration to your command line. Whether you're dealing with old family photos, blurry portraits, or low-resolution images, ScaleX aims to revitalize them with remarkable clarity and detail. It intelligently combines face-specific enhancement using **GFPGAN** models with optional background upscaling via **Real-ESRGAN**.
2237

38+
This project focuses on delivering a refined and accessible experience by:
39+
40+
- Upgrading the core to **Python 3.12**.
41+
- Providing an **enhanced CLI** with clear options and rich progress feedback (thanks to Typer and Rich).
42+
- Automating fixes for common **dependency issues**.
43+
- Streamlining **model downloads** with user-friendly progress bars.
44+
2345
---
2446

2547
## ✨ Features
48+
2649
- 🚀 **High-Quality Face Restoration:** Leverages **GFPGAN v1.3 & v1.4** models.
2750
- 🖼️ **Background Enhancement:** Optional background upscaling with **Real-ESRGAN x2plus & x4plus**.
2851
- 📈 **Overall Image Upscaling:** Control the final output resolution (e.g., 2x, 4x).
@@ -38,96 +61,159 @@ ScaleX brings cutting-edge AI face restoration to your command line. Whether you
3861
---
3962

4063
## 🛠️ Installation
64+
4165
### 📋 Prerequisites
66+
4267
- 🐍 [Python](https://www.python.org/) 3.12
43-
- 🐉 [Anaconda](https://www.anaconda.com/download) or [Miniconda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html) (Recommended for PyTorch)
44-
- 📦 [pip](https://pypi.org/project/pip/)
45-
-[Git](https://git-scm.com/)
46-
- 🔥 [PyTorch](https://pytorch.org/) (Installation instructions below)
68+
- 🐉 [Anaconda](https://www.anaconda.com/download) or [Miniconda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html) (Required for the automated installation scripts and recommended for PyTorch)
69+
-[Git](https://git-scm.com/) (To clone the repository)
4770
-**For GPU Acceleration (Optional but Recommended):**
48-
- NVIDIA GPU + Up-to-date [CUDA Drivers](https://www.nvidia.com/Download/index.aspx)
71+
- NVIDIA GPU + Up-to-date [CUDA Drivers](https://www.nvidia.com/Download/index.aspx)
72+
73+
### 🚀 Automated Installation (Recommended)
74+
75+
1. **Clone the Repository:**
76+
77+
```bash
78+
git clone https://github.com/Md-Siam-Mia-Code/ScaleX-CLI.git
79+
cd ScaleX-CLI
80+
```
81+
82+
2. **Run the Installation Script:**
83+
The scripts will guide you through creating a Conda environment, choosing a PyTorch version (CPU/GPU), and installing all dependencies.
84+
85+
- **For Windows:**
86+
Open a Command Prompt (cmd.exe) or PowerShell in the `ScaleX-CLI` directory and run:
87+
88+
```batch
89+
install_scalex_windows.bat
90+
```
91+
92+
- **For Linux / macOS:**
93+
Open your terminal in the `ScaleX-CLI` directory, make the script executable, then run it:
94+
`bash
95+
chmod +x install_scalex.sh
96+
./install_scalex_linux.sh
97+
`
98+
Follow the on-screen prompts provided by the script.
99+
100+
### 🔩 Manual Installation
101+
102+
If you prefer to set up the environment manually:
103+
104+
1. **Clone the Repository:**
49105

50-
### 💾 Steps
51-
1. **Clone the Repository**
52106
```bash
53107
git clone https://github.com/Md-Siam-Mia-Code/ScaleX-CLI.git
54108
cd ScaleX-CLI
55109
```
56110

57-
2. **Create and Activate Conda Environment**
111+
2. **Create and Activate Conda Environment:**
112+
58113
```bash
59114
conda create -n ScaleX-CLI python=3.12 -y
60115
conda activate ScaleX-CLI
61116
```
62117

63-
3. **Install PyTorch**
64-
Visit the [PyTorch official website](https://pytorch.org/get-started/locally/) to get the correct installation command for your system (OS, package manager, CUDA version if applicable).
118+
3. **Install PyTorch:**
119+
Visit the [PyTorch official website](https://pytorch.org/get-started/locally/) to get the correct `conda install` command for your system (OS, package manager, CUDA version if applicable).
120+
121+
_Example for CPU-only (conda):_
65122

66-
*For CPU-only (conda):*
67123
```bash
68124
conda install pytorch torchvision torchaudio cpuonly -c pytorch -y
69125
```
70-
*For CUDA (conda):*
126+
127+
_Example for CUDA (conda):_
128+
71129
```bash
72130
conda install pytorch torchvision torchaudio pytorch-cuda=<your-cuda-version> -c pytorch -c nvidia -y
73131
```
74-
*(Adjust the CUDA version as needed for your setup)*
75132

76-
4. **Install Dependencies**
133+
_(Adjust the CUDA version as needed for your setup)_
134+
135+
4. **Install Dependencies:**
77136
```bash
78137
pip install -r requirements.txt
79138
```
80139

81-
5. **Model Downloads**
82-
🚀 *Required models (GFPGAN, Real-ESRGAN, facexlib components) will be automatically downloaded with a progress bar when you run the application for the first time if they are not found in the `models/pretrained/` directory.*
140+
5. **Model Downloads:**
141+
🚀 _Required models (GFPGAN, Real-ESRGAN, facexlib components) will be automatically downloaded with a progress bar when you run the application for the first time if they are not found in the `models/pretrained/` directory._
83142

84143
---
85144

86145
## 💻 Usage
146+
87147
### ▶️ Running ScaleX
88-
Navigate to the `ScaleX` directory in your terminal (ensure your `ScaleX` conda environment is activated).
89-
The main script is `inference_scalex.py`.
148+
149+
After successful installation:
150+
151+
1. Open your terminal or Anaconda Prompt.
152+
2. Activate the Conda environment: `conda activate ScaleX-CLI`
153+
3. Navigate to the `ScaleX-CLI` directory.
154+
4. Run the main script `inference_scalex.py`.
90155

91156
**Basic Command Structure:**
157+
92158
```bash
93159
python inference_scalex.py --input <path_to_input> --output <path_to_output_folder> [OPTIONS]
94160
```
95161

96162
**Example:**
97163
To process all images in a folder named `MyPhotos` and save results to `EnhancedPhotos`, using GFPGAN v1.4, RealESRGAN x4 for background, and upscaling the final image by 4x:
98-
```bash
164+
165+
````bash
99166
python inference_scalex.py -i MyPhotos/ -o EnhancedPhotos/ -f v1.4 -b x4 -s 4
100167
```
101168
102169
### ⚙️ Key Options
103170
* `-i, --input PATH`: **Required.** Path to your input image or a folder containing images.
104-
* `-o, --output PATH`: Folder where results will be saved. (Default: `Output`)
171+
* `-o, --output PATH`: Folder where results will be saved. (Default: `results_scalex`)
105172
* `-f, --face-enhance [v1.3|v1.4]`: Choose the GFPGAN model for face restoration. (Default: `v1.4`)
106173
* `-b, --bg-enhance [none|x2|x4]`: Background enhancement model.
107174
* `none`: No background processing.
108-
* `x2`: RealESRGAN x2plus (2x background upscale relative to its input).
109-
* `x4`: RealESRGAN x4plus (4x background upscale relative to its input).
175+
* `x2`: RealESRGAN x2plus.
176+
* `x4`: RealESRGAN x4plus.
110177
(Default: `x2`)
111178
* `-s, --upscale INTEGER`: The final desired upscaling factor for the *entire image*. (Default: `2`)
112-
* `--bg-tile INTEGER`: Tile size for background upsampler to manage memory. 0 disables tiling (faster if memory allows). (Default: `400`)
113-
* `--device [auto|cpu|cuda|mps]`: Select computation device. `auto` will try GPU first. (Default: `auto`)
114-
* `--aligned`: Use this if your input images are already 512x512 aligned faces. Skips face detection.
115-
* `--ext [auto|png|jpg]`: Extension for saved output images. `auto` tries to match input. (Default: `auto`)
179+
* `--bg-tile INTEGER`: Tile size for background upsampler to manage memory. 0 disables tiling. (Default: `400`)
180+
* `--device [auto|cpu|cuda|mps]`: Select computation device. (Default: `auto`)
181+
* `--aligned`: Use this if your input images are already 512x512 aligned faces.
182+
* `--ext [auto|png|jpg]`: Extension for saved output images. (Default: `auto`)
116183
* `--no-save-cropped`: Do not save the initial cropped faces.
117184
* `--no-save-restored`: Do not save the individually restored faces.
118185
* `--no-save-comparison`: Do not save the side-by-side comparison images.
119186
120-
**Get Help:**
121-
For a full list of all available options and their descriptions:
187+
**Get Full Help:**
188+
For a comprehensive list of all available options and their descriptions:
122189
```bash
123190
python inference_scalex.py --help
124-
```
191+
````
192+
193+
---
194+
195+
## 💡 Troubleshooting
196+
197+
- **`ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'`**:
198+
ScaleX includes an automated patch (`patches.py`) for this common `basicsr`/`torchvision` issue. It should be applied automatically. If you see this, ensure `patches.py` is present and correctly imported at the start of `inference_scalex.py`.
199+
- **Model Download Issues**:
200+
- Check your internet connection.
201+
- If a download seems stuck or corrupt, try deleting the specific `.pth` file from the `models/pretrained/` directory within your ScaleX project folder and re-run.
202+
- **GPU (CUDA / MPS) Errors**:
203+
- **NVIDIA CUDA:** Ensure your NVIDIA drivers are up-to-date and that you installed the PyTorch version matching your system's CUDA toolkit version.
204+
- **Apple MPS:** Ensure you are on a compatible macOS and PyTorch version.
205+
- Test with `--device cpu` to isolate if the problem is GPU-specific.
206+
- **Installation Script Issues**:
207+
- Ensure Conda is installed and its `bin` or `Scripts` directory is in your system's PATH, or that Conda has been initialized for your shell (e.g., via `conda init bash` or `conda init cmd.exe`).
208+
- **Other `ModuleNotFoundError`s**:
209+
Make sure you have activated the correct conda environment (`conda activate ScaleX-CLI`) and that all packages from `requirements.txt` were installed successfully.
125210
126211
---
127212
128213
## 🤝 Contributing
214+
129215
🎉 Contributions, issues, and feature requests are welcome!
130-
Feel free to check [issues page](https://github.com/[YourGitHubUsername]/ScaleX/issues). You can also fork the repository and submit a pull request.
216+
Feel free to check the [issues page](https://github.com/Md-Siam-Mia-Code/ScaleX-CLI/issues). You can also fork the repository and submit a pull request.
131217
132218
1. Fork the Project
133219
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
@@ -138,15 +224,18 @@ Feel free to check [issues page](https://github.com/[YourGitHubUsername]/ScaleX/
138224
---
139225
140226
## 📜 Acknowledgments & License
227+
141228
ScaleX is built upon and inspired by the incredible work of the open-source community. Special thanks to the creators and maintainers of:
142-
* **GFPGAN:** [TencentARC/GFPGAN](https://github.com/TencentARC/GFPGAN)
143-
* **Real-ESRGAN:** [xinntao/Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN)
144-
* **BasicSR:** [xinntao/BasicSR](https://github.com/xinntao/BasicSR)
145-
* **facexlib:** [xinntao/facexlib](https://github.com/xinntao/facexlib)
146-
* **Typer & Rich:** For the excellent CLI and console UI libraries.
147229
148-
*(Note: The underlying models and libraries (GFPGAN, Real-ESRGAN, etc.) have their own licenses which should also be respected.)*
230+
- **GFPGAN:** [TencentARC/GFPGAN](https://github.com/TencentARC/GFPGAN)
231+
- **Real-ESRGAN:** [xinntao/Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN)
232+
- **BasicSR:** [xinntao/BasicSR](https://github.com/xinntao/BasicSR)
233+
- **facexlib:** [xinntao/facexlib](https://github.com/xinntao/facexlib)
234+
- **Typer & Rich:** For the excellent CLI and console UI libraries.
235+
236+
This project is licensed under the **MIT License**. Please see the `LICENSE` file for more details.
237+
_(Note: The underlying models and libraries (GFPGAN, Real-ESRGAN, etc.) have their own licenses which should also be respected.)_
149238
150239
---
151240
152-
# ❤️ *Happy Enhancing with ScaleX!*
241+
❤️ _Happy Enhancing with ScaleX!_

0 commit comments

Comments
 (0)