Don<p><strong>Transforming Family Photos into Festive Holiday Cards with AI</strong></p><p>There are several open-source tools available this year for creating holiday cards. If you have a wonderful photo of your family or grandchildren, but it was taken during a different season and you’d like to change the background, there’s a Python module called <strong>rembg</strong> that can help you with that. To get started, you’ll need to set up a Python virtual environment and install the necessary dependencies. I created a directory named <strong>rembg</strong> using the following command:</p><pre><code>$ mkdir rembg </code></pre><p>Then I setup a Python virtual environment.</p><p><code>python3 -m venv /home/don/rembg</code></p><p>Then I activate the environment with the following command.</p><p><code>source /home/don/rembg/bin/activate</code></p><p>Then I install <strong>rembg</strong>:</p><p><code>pip3 install rembg</code></p><p>I want to use rembg from the command line so I make the following additional installation:</p><p><code>pip3 install "rembg[cli]"</code></p><p>Then I install <strong>onnxruntime</strong> which is a [machine learning accelerator](<a href="https://github.com/microsoft/onnxruntime" rel="nofollow noopener" target="_blank">GitHub – microsoft/onnxruntime: ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator</a>).</p><p><code>pip3 install onnxruntime</code></p><p>Now I am ready to remove the background from the image that I have chosen. This is a recent picture of my wife and I taken in the fall of the year. I like the picture but I want it to have a festive background.</p>Photo by <a href="https://www.sissyhorch.com/" rel="nofollow noopener" target="_blank">https://www.sissyhorch.com/</a><p>I make sure that my image is in the <strong>rembg</strong> folder and then execute the following command. The <strong>i</strong> switch means that I am operating at the file level.</p><p><code>rembg i grandparents.jpg grandparents_no_bg.jpg</code></p><p>In the command above I renamed the output file so that I would still have my original just in case I wanted to use it again. You can see below that the background has been removed from the image above.</p><p>I can create a nice background for my card with InkScape and add some festive lettering and use a Pointsettia I downloaded from <a href="https://openclipart.org" rel="nofollow noopener" target="_blank">Openclipart.org</a>. The completed card is shown below.</p>Created with InkScape, OpenClipart.org by Don Watkins CC by SA 4.0<p></p><p><a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://donwatkins.info/tag/ai/" target="_blank">#AI</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://donwatkins.info/tag/python/" target="_blank">#Python</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://donwatkins.info/tag/rembg/" target="_blank">#rembg</a></p>