{"id":19256687,"url":"https://github.com/markmohr/sketch-photo2seq","last_synced_at":"2025-07-06T08:02:16.016Z","repository":{"id":110991326,"uuid":"183120844","full_name":"MarkMoHR/sketch-photo2seq","owner":"MarkMoHR","description":"Reimplementation of paper \"Learning to Sketch with Shortcut Cycle Consistency\"(CVPR 2018)","archived":false,"fork":false,"pushed_at":"2019-04-27T03:17:01.000Z","size":328,"stargazers_count":19,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T15:40:44.163Z","etag":null,"topics":["cycle-consistency","photo-to-sketch","sketch","sketch-generation","sketch-synthesis","vector-sketch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarkMoHR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-24T01:12:51.000Z","updated_at":"2024-09-20T15:25:53.000Z","dependencies_parsed_at":"2023-04-04T01:49:47.366Z","dependency_job_id":null,"html_url":"https://github.com/MarkMoHR/sketch-photo2seq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarkMoHR/sketch-photo2seq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkMoHR%2Fsketch-photo2seq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkMoHR%2Fsketch-photo2seq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkMoHR%2Fsketch-photo2seq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkMoHR%2Fsketch-photo2seq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarkMoHR","download_url":"https://codeload.github.com/MarkMoHR/sketch-photo2seq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkMoHR%2Fsketch-photo2seq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263868205,"owners_count":23522315,"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","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":["cycle-consistency","photo-to-sketch","sketch","sketch-generation","sketch-synthesis","vector-sketch"],"created_at":"2024-11-09T19:06:36.005Z","updated_at":"2025-07-06T08:02:16.010Z","avatar_url":"https://github.com/MarkMoHR.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sketch-photo2seq\n\nThis is the reimplementation code of CVPR'2018 paper [Learning to Sketch with Shortcut Cycle Consistency](http://openaccess.thecvf.com/content_cvpr_2018/papers/Song_Learning_to_Sketch_CVPR_2018_paper.pdf).\n\n| Photo | Generated examples |\n| --- | --- |\n| ![example1](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/assets/QMUL/2482805404/photo_gt.png) | ![example1-sketch](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/assets/QMUL/2482805404/sketch_pred_multi.svg) |\n| ![example2](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/assets/QMUL/2509386515/photo_gt.png) | ![example2-sketch](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/assets/QMUL/2509386515/sketch_pred_multi.svg) |\n\n\n## Requirements\n\n- Python 3\n- Tensorflow (\u003e= 1.4.0)\n- [InkScape](https://inkscape.org/) or [CairoSVG](https://cairosvg.org/) (For vector sketch rendering. Choose one of them is ok.)\n\n  ```\n  sudo apt-get install inkscape\n  # or\n  pip3 install cairosvg\n  ```\n\n\n## Data Preparations\nFrom the paper, we need to pre-train the model on the [*QuickDraw*](https://github.com/googlecreativelab/quickdraw-dataset#sketch-rnn-quickdraw-dataset) dataset. So we need to preprocess both the *QuickDraw-shoes* and *QMUL-shoes* data following these steps:\n\n1. QuickDraw-shoes\n\n    - Download the `sketchrnn_shoes.npz` data from [*QuickDraw*](https://github.com/googlecreativelab/quickdraw-dataset#sketch-rnn-quickdraw-dataset)\n    - Place the package under `datasets/QuickDraw/shoes/npz/` directory\n    - run the command:\n      ```\n      python quickdraw_data_processing.py\n      ```\n\n1. QMUL-shoes\n\n    - Download the photo data from [QMUL-Shoe-Chair-V2](http://www.eecs.qmul.ac.uk/~qian/Project_cvpr16.html)\n    - Unzip the *ShoeV2_photo* package and place all `.png` under `datasets/QMUL/shoes/photos/` directory\n    - Download the preprocessed sketch data from [here](https://drive.google.com/drive/folders/15-1NQXGFUEaQkM0EvefdTWP9tBHRZ2jp) and place the two `.h5` packages under `datasets/QMUL/shoes/` directory\n\n\n## Training\n\n1. QuickDraw-shoes pre-training\n\n    - Change the value to `QuickDraw` in [`model.py`](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/model.py)-`get_default_hparams`-`data_type`\n    - run the command:\n      ```\n      python sketch_p2s_train.py\n      ```\n\n1. QMUL-shoes training\n\n    - Change the value to `QMUL` in [`model.py`](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/model.py)-`get_default_hparams`-`data_type`\n    - Make sure the QuickDraw-shoes pre-training models/checkpoint are placed under `outputs/snapshot/` directory\n    - Change the value to `True` in [`sketch_p2s_train.py`](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/sketch_p2s_train.py)-`resume_training`\n    - run the command:\n      ```\n      python sketch_p2s_train.py\n      ```\n      \n#### Training loss\n\nThe following figure shows the total *loss*, *KL loss* and *reconstruction loss* during training with QuickDraw-shoes pre-trained within 30k iterations and the following QMUL-shoes trained within 40k iterations.\n\n![loss](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/assets/loss.png)\n\n\n## Sampling\n\n1. QuickDraw-shoes\n\n    - Make sure the value of `data_type` to be `QuickDraw` in [`model.py`](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/model.py)\n    - Place models/checkpoint/config under `outputs/snapshot/QuickDraw/` directory\n    - run the command:\n      ```\n      python sketch_p2s_sampling.py\n      ```\n\n1. QMUL-shoes\n\n    - Make sure the value of `data_type` to be `QMUL` in [`model.py`](https://github.com/MarkMoHR/sketch-photo2seq/blob/master/model.py)\n    - Place models/checkpoint/config under `outputs/snapshot/QMUL/` directory\n    - run the command:\n      ```\n      python sketch_p2s_sampling.py\n      ```\n\nAll results can be found under `outputs/sampling/` dir.\n\n\n\n## Credits\n- This code is largely borrowed from repos [Sketch-RNN](https://github.com/tensorflow/magenta/tree/master/magenta/models/sketch_rnn) and [deep_p2s](https://github.com/seindlut/deep_p2s).\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmohr%2Fsketch-photo2seq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkmohr%2Fsketch-photo2seq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmohr%2Fsketch-photo2seq/lists"}