a simple version for blind text image super-resolution (current version is only for English and Chinese)
Project description
Update v0.1.12
- Support text region with different angle.
- Higher resolution. min(height, width) of output is 256 (128 in v0.24.0)
See our project page for more details: https://github.com/csxmli2016/textbsr
This is a simple text image super-resolution package.
More details can be found in our Project Page: https://github.com/csxmli2016/textbsr
This package can post-process the text region with a simple command, i.e.,
textbsr -i [LR_TEXT_PATH] -b [BACKGROUND_SR_PATH]
- [LR_TEXT_PATH] is the LR image path.
- [BACKGROUND_SR_PATH] stores the results from any blind image super-resolution methods.
- If the text image is degraded severely, this method may still fail to obtain a plausible result.
Dependencies and Installation
- numpy
- cnstd
- torch>=1.8.1
- torchvision>=0.9
# Install with pip
pip install textbsr
Basic Usage
# On the terminal command
textbsr -i [LR_TEXT_PATH]
or
# On the python environment
from textbsr import textbsr
textbsr.bsr(input_path='./testsets/LQs')
Parameter details:
parameter name | default | description |
---|---|---|
-i, --input_path | - | The lr text image path. It can store full images or text layouts only. |
-b, --bg_path | None | The background sr path from other methods. If None, we only restore the text region detected by cnstd. |
-o, --output_path | None | The save path for text sr result. If None, we save the results on the same path with the format of [input_path]_TIMESTAMP. |
-a, --aligned | False | action='store_true'. If True, the input text image contains only text region. If False, we use CnSTD to detect text regions and then restore them. |
-s, --save_text | False | action='store_true'. If True, save the LR and SR text layout. |
-d, --device | None | Device, use 'gpu' or 'cpu'. If None, we use torch.cuda.is_available to select the device. |
Example for post-processing the text region
# On the terminal command
textbsr -i [LR_TEXT_PATH] -b [BACKGROUND_SR_PATH] -s
or
# On the python environment
from textbsr import textbsr
textbsr.bsr(input_path='./testsets/LQs', bg_path='./testsets/RealESRGANResults', save_text=True)
When [BACKGROUND_SR_PATH] is None, we only restore the text region and paste it back to the LR input, with the background region unchanged.
Example for restoring the aligned text region
# On the terminal command
textbsr -i [LR_TEXT_PATH] -a
or
# On the python environment
from textbsr import textbsr
textbsr.bsr(input_path='./testsets/LQs', aligned=True)
If you find this package helpful, please kindly consider citing our paper:
@InProceedings{li2023marconet,
author = {Li, Xiaoming and Zuo, Wangmeng and Loy, Chen Change},
title = {Learning Generative Structure Prior for Blind Text Image Super-resolution},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year = {2023}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file textbsr-0.1.12.tar.gz
.
File metadata
- Download URL: textbsr-0.1.12.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc71fec4119d5e6f656679f7adaf55b9d390ec8b4de508604461d3c050f92d8 |
|
MD5 | 0147b332cf040ef3ec7395c43cb6da6a |
|
BLAKE2b-256 | 83c30810ba664432e956270810e935ed5bf7252c3a417bd333dbfbdac7eed3d1 |
File details
Details for the file textbsr-0.1.12-py3-none-any.whl
.
File metadata
- Download URL: textbsr-0.1.12-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adaa1799259b5a18b84efaded1523188ddc763928003cb639507ef756d5c19dd |
|
MD5 | 13d5636038ebdd66fda05ad4c4bc9648 |
|
BLAKE2b-256 | da0b267d3298fe0f84cc7ecf24746678ba69622fca629d160765fb21389404e2 |