{"id":20663733,"url":"https://github.com/vita-group/shapematchinggan","last_synced_at":"2025-09-09T05:43:49.247Z","repository":{"id":50323224,"uuid":"200440204","full_name":"VITA-Group/ShapeMatchingGAN","owner":"VITA-Group","description":"[ICCV 2019, Oral] Controllable Artistic Text Style Transfer via Shape-Matching GAN","archived":false,"fork":false,"pushed_at":"2022-05-08T06:23:09.000Z","size":6382,"stargazers_count":427,"open_issues_count":4,"forks_count":67,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-25T22:03:56.498Z","etag":null,"topics":["gans","iccv19","pytorch","style-transfer"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VITA-Group.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-04T02:21:57.000Z","updated_at":"2025-05-04T00:54:17.000Z","dependencies_parsed_at":"2022-08-12T21:02:21.940Z","dependency_job_id":null,"html_url":"https://github.com/VITA-Group/ShapeMatchingGAN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VITA-Group/ShapeMatchingGAN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FShapeMatchingGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FShapeMatchingGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FShapeMatchingGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FShapeMatchingGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VITA-Group","download_url":"https://codeload.github.com/VITA-Group/ShapeMatchingGAN/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VITA-Group%2FShapeMatchingGAN/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274250508,"owners_count":25249396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gans","iccv19","pytorch","style-transfer"],"created_at":"2024-11-16T19:19:33.826Z","updated_at":"2025-09-09T05:43:49.222Z","avatar_url":"https://github.com/VITA-Group.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShapeMatchingGAN\n\n\u003ctable border=\"0\" width='100%'\u003e\n \u003ctr align=\"center\"\u003e\n  \u003ctd width=\"14.5%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-a.jpg\" width=\"100%\" \u003e\u003c/td\u003e\n  \u003ctd width=\"32%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-b.png\" width=\"99%\" \u003e\u003c/td\u003e\n  \u003ctd width=\"33%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-c.gif\" width=\"99%\" \u003e\u003c/td\u003e\t\n  \u003ctd width=\"18.6%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-d.gif\" width=\"99%\" \u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr align=\"center\"\u003e\n  \u003ctd\u003esource\u003c/td\u003e\u003ctd\u003eadjustable stylistic degree of glyph\u003c/td\u003e\u003ctd\u003estylized text\u003c/td\u003e\u003ctd\u003eapplication\u003c/td\u003e\n\u003c/tr\u003e\t\t\t\t\t \n \u003c/table\u003e\n \u003ctable border=\"0\" width='100%'\u003e\n \u003ctr align=\"center\"\u003e\n  \u003ctd width=\"50%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-e.gif\" alt=\"\" width=\"99%\" \u003e\u003c/td\u003e\t\n  \u003ctd width=\"50%\"\u003e\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/teaser-f.gif\" alt=\"\" width=\"99%\" \u003e\u003c/td\u003e\t\t\t\t\t\t\n \u003c/tr\u003e\t\t\t\t\t \n \u003ctr align=\"center\"\u003e\n  \u003ctd\u003eliquid artistic text rendering\u003c/td\u003e\u003ctd\u003esmoke artistic text rendering\u003c/td\u003e\n\u003c/tr\u003e\t\n\u003c/table\u003e\n\nThis is a pytorch implementation of the paper.\n\nShuai Yang, Zhangyang Wang, Zhaowen Wang, Ning Xu, Jiaying Liu and Zongming Guo.\nControllable Artistic Text Style Transfer via Shape-Matching GAN, \naccepted by International Conference on Computer Vision (ICCV), 2019.\n\n[[Project]](https://williamyang1991.github.io/projects/ICCV2019/SMGAN.html) | [[Paper]](https://arxiv.org/abs/1905.01354) | More about artistic text style transfer [[Link]](https://williamyang1991.github.io/index.html#publications)\n\nPlease consider citing our paper if you find the software useful for your work.\n\n\n## Usage: \n\n#### Prerequisites\n- Python 2.7\n- Pytorch 1.1.0\n- matplotlib\n- scipy\n- Pillow\n\n#### Install\n- Clone this repo:\n```\ngit clone https://github.com/TAMU-VITA/ShapeMatchingGAN.git\ncd ShapeMatchingGAN/src\n```\n## Testing Example\n\n- Download pre-trained models from [[Google Drive]](https://drive.google.com/open?id=1gjHR39deUSPChtRbKAD80waoQFTiXyMs) or [[Baidu Cloud]](https://pan.baidu.com/s/1tvTCig4OQhixX_EzSzYQSg)(code:rjpi) to `../save/`\n- Artisic text style transfer using \u003ci\u003efire\u003c/i\u003e style with scale 0.0\n  - Results can be found in `../output/`\n\n\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/test.jpg\" width=\"60%\" height=\"60%\"\u003e\n\n```\npython test.py \\\n--scale 0.0\n--structure_model ../save/fire-GS-iccv.ckpt \\\n--texture_model ../save/fire-GT-iccv.ckpt \\\n--gpu\n```\n- Artisic text style transfer with specified parameters\n  - setting scale to -1 means testing with multiple scales in \\[0,1\\] with step of scale_step\n  - specify the input text name, output image path and name with text_name, result_dir and name, respectively\n```\npython test.py \\\n--text_name ../data/rawtext/yaheiB/val/0801.png \\\n--scale -1 --scale_step 0.2 \\\n--structure_model ../save/fire-GS-iccv.ckpt \\\n--texture_model ../save/fire-GT-iccv.ckpt \\\n--result_dir ../output --name fire-0801 \\\n--gpu\n```\nor just modifying and running\n```\nsh ../script/launch_test.sh\n```\n- For black and white text images, use option `--text_type 1`\n  - utils.text_image_preprocessing will transform BW images into distance-based images\n  - distance-based images make the network better deal with the saturated regions\n\n## Training Examples\n\n### Training Sketch Module G_B\n\n- Download text dataset from [[Google Drive]](https://drive.google.com/open?id=1gjHR39deUSPChtRbKAD80waoQFTiXyMs) or [[Baidu Cloud]](https://pan.baidu.com/s/1tvTCig4OQhixX_EzSzYQSg)(code:rjpi) to `../data/`\n\n- Train G_B with default parameters\n  - Adding augmented images to the training set can make G_B more robust\n```\npython trainSketchModule.py \\\n--text_path ../data/rawtext/yaheiB/train --text_datasize 708 \\\n--augment_text_path ../data/rawtext/augment --augment_text_datasize 5 \\\n--batchsize 16 --Btraining_num 12800 \\\n--save_GB_name ../save/GB.ckpt \\\n--gpu\n```\nor just modifying and running\n```\nsh ../script/launch_SketchModule.sh\n```\nSaved model can be found at `../save/`\n- Use `--help` to view more training options\n```\npython trainSketchModule.py --help\n```\n  \n### Training Structure Transfer G_S\n\n- Train G_S with default parameters\n  - step1: G_S is first trained with a fixed \u003ci\u003el\u003c/i\u003e = 1 to learn the greatest deformation\n  - step2: we then use \u003ci\u003el\u003c/i\u003e ∈ {0, 1} to learn two extremes\n  - step3: G_S is tuned on \u003ci\u003el\u003c/i\u003e ∈ {i/K}, i=0,...,K where K = 3 (i.e. --scale_num 4)\n  - for structure with directional patterns, training without `--Sanglejitter` will be a good option\n```\npython trainStructureTransfer.py \\\n--style_name ../data/style/fire.png \\\n--batchsize 16 --Straining_num 2560 \\\n--step1_epochs 30 --step2_epochs 40 --step3_epochs 80 \\\n--scale_num 4 \\\n--Sanglejitter \\\n--save_path ../save --save_name fire \\\n--gpu\n```\nor just modifying and running\n```\nsh ../script/launch_ShapeMGAN_structure.sh\n```\nSaved model can be found at `../save/`\n- To preserve the glyph legibility (Eq. (7) in the paper), use option `--glyph_preserve`\n  - need to specify the text dataset `--text_path ../data/rawtext/yaheiB/train` and `--text_datasize 708`\n  - need to load pre-trained G_B model `--load_GB_name ../save/GB-iccv.ckpt`\n  - in most cases, `--glyph_preserve` is not necessary, since one can alternatively use a smaller \u003ci\u003el\u003c/i\u003e\n- Use `--help` to view more training options\n```\npython trainStructureTransfer.py --help\n```\n\n### Training Texture Transfer G_T\n\n- Train G_T with default parameters\n  - for complicated style or style with directional patterns, training without `--Tanglejitter` will be a good option\n```\npython trainTextureTransfer.py \\\n--style_name ../data/style/fire.png \\\n--batchsize 4 --Ttraining_num 800 \\\n--texture_step1_epochs 40 \\\n--Tanglejitter \\\n--save_path ../save --save_name fire \\\n--gpu\n```\nor just modifying and running\n```\nsh ../script/launch_ShapeMGAN_texture.sh\n```\nSaved model can be found at `../save/`\n- To train with style loss, use option `--style_loss`\n  - need to specify the text dataset `--text_path ../data/rawtext/yaheiB/train` and `--text_datasize 708`\n  - need to load pre-trained G_S model `--load_GS_name ../save/fire-GS.ckpt`\n  - adding `--style_loss` can slightly improve the texture details\n- Use `--help` to view more training options\n```\npython trainTextureTransfer.py --help\n```\n\n### More\n\nThree training examples are in the IPythonNotebook ShapeMatchingGAN.ipynb\n\nHave fun :-)\n\n### Try with your own style images\n\n- Style image preparation \n  - Applicable style types: To make the stylized text easy to recognize, it is desirable to have a certain distinction between the text and the background. If the texture has no distinct shape, the generated stylized text will be mixed with the background. Therefore, textures with distinct shapes as the reference style are recommended.\n  - Prepare (X,Y): Use Image Matting Algorithm or the Quick Selection Tool in Photoshop to obtain the black and white structure map X (i.e. foreground mask) of the style image Y. \n  - Prepare distance-based structure map: Use utils.text_image_preprocessing to transform black and white X into distance-based X.\n  - Concatenate distance-based X with Y as the format of images in `../data/style/` and copy the result to `../data/style/`.\n\n\u003cimg src=\"https://github.com/williamyang1991/ShapeMatchingGAN/blob/master/imgs/failure.jpg\" width=\"90%\" height=\"90%\"\u003e\n\n### Contact\n\nShuai Yang\n\nwilliamyang@pku.edu.cn\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvita-group%2Fshapematchinggan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvita-group%2Fshapematchinggan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvita-group%2Fshapematchinggan/lists"}