How to Use the Photo-Sketching Repository: A Beginner’s Guide

Oct 9, 2021 | Educational

Ever wondered how to convert images into beautiful contour drawings? The Photo-Sketching project is here to help! In this guide, we’ll walk you through setting up and using the sketch generator, even if you have minimal programming experience. Let’s jump right in!

Getting Started with Installation

This project uses PyTorch to build its functionality, and it’s compatible with Windows, macOS, and Linux. Here’s how to install it smoothly:

One-Line Installation (with Conda environments)

  • To get started quickly, simply run this command in your terminal:
  • conda env create -f environment.yml
  • Then activate the environment:
  • conda activate sketch
  • You’re ready to go! For more information on managing conda environments, check out this guide.

Manual Installation

If you prefer to install manually, refer to environment.yml for a list of dependencies required for this project.

Using the Pre-trained Model

Now that you’ve got everything set up, you can use the pre-trained model to generate sketches from images.

  • First, download the pre-trained model using this link.
  • Next, modify the path in scripts/test_pretrained.sh to point to the downloaded model.
  • Finally, run the script from the repository’s root directory by executing:
  • bash scripts/test_pretrained.sh
  • This script supports a folder of images as input, so feel free to try out different images!

Training and Testing on the Dataset

If you’re eager to train the model from scratch, here’s how you can do it:

  • First, download the images and rendered sketches from the project page.
  • Unzip and organize them into the following structure:
  • File Structure
  • Modify the path in scripts/train.sh and scripts/test.sh.
  • From the repository’s root directory, run:
  • bash scripts/train.sh
  • To test on the validation or test set, use:
  • bash scripts/test.sh
  • The ‘phase’ flag lets you specify which dataset to test on.

Understanding the Code: An Analogy

Think of the Photo-Sketching repository as a talented chef’s kitchen. The images you provide are like the fresh ingredients you give the chef. The pre-trained model is the chef with years of experience ready to transform these ingredients into exquisite dishes (sketches). The training setup is akin to gathering all the necessary tools and utensils to ensure everything runs smoothly while creating your masterpiece.

Troubleshooting Tips

While you’re using the Photo-Sketching tool, you might encounter a few bumps along the way. Here are some tips to help you troubleshoot common issues:

  • Environment Errors: Ensure that you have activated the correct conda environment.
  • File Not Found: Double-check that you modified the paths correctly in the shell scripts.
  • Model Not Loading: Verify that you’ve downloaded the pre-trained model and its path is correctly set.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

By following this guide, you should now be well-equipped to leverage the Photo-Sketching repository to create mesmerizing contour drawings from photographs. Learning how to apply AI technologies can unlock new artistic potentials, and we’re excited for you to explore it!

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox