<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Python on myByways</title><link>https://myByways.com/tags/python/</link><description>Recent content in Python on myByways</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 19 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://myByways.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Convert animated WebP to WebM movie with Python</title><link>https://myByways.com/post/convert-animated-webp-to-webm-movie-with-python/</link><pubDate>Sun, 21 Jan 2024 00:00:00 +0000</pubDate><guid>https://myByways.com/post/convert-animated-webp-to-webm-movie-with-python/</guid><description>&lt;p&gt;In &lt;a href="https://myByways.com/post/comparing-face-ip-adapters-for-sdxl"&gt;my last post&lt;/a&gt; I mentioned converting an animated &lt;a href="https://en.wikipedia.org/wiki/WebP" rel="external"&gt;WebP&lt;/a&gt; image format into a &lt;a href="https://en.wikipedia.org/wiki/WebM" rel="external"&gt;WebM&lt;/a&gt; movie format. This post expands on how I did it.&lt;/p&gt;</description></item><item><title>Extracting images from PDF files</title><link>https://myByways.com/post/extracting-images-from-pdf-files/</link><pubDate>Sat, 06 Jan 2024 00:00:00 +0000</pubDate><guid>https://myByways.com/post/extracting-images-from-pdf-files/</guid><description>&lt;p&gt;Happy new year!&lt;/p&gt;
&lt;p&gt;Ever needed to extract images from PDFs and found both on-line and off-line tools lacking? Well, I certainly have, and here I present my Python code to extract JPGs/PNGs from PDFs, using &lt;a href="https://github.com/pymupdf/PyMuPDF" rel="external"&gt;PyMuPDF&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Run code in a macOS Sandbox</title><link>https://myByways.com/post/run-code-in-a-macos-sandbox/</link><pubDate>Sun, 11 Jun 2023 00:00:00 +0000</pubDate><guid>https://myByways.com/post/run-code-in-a-macos-sandbox/</guid><description>&lt;p&gt;I sometimes test randomly downloaded code on macOS in a &lt;strong&gt;Sandbox&lt;/strong&gt; that has limited and network access. I posted about this way back in Jan 2017, &lt;a href="https://myByways.com/post/creating-a-macos-sandbox-to-run-kodi"&gt;Creating a macOS Sandbox to run Kodi&lt;/a&gt;, and this is a short refresher for me&amp;hellip;&lt;/p&gt;</description></item><item><title>Create an animated PNG</title><link>https://myByways.com/post/create-an-animated-png/</link><pubDate>Fri, 09 Jun 2023 00:00:00 +0000</pubDate><guid>https://myByways.com/post/create-an-animated-png/</guid><description>&lt;p&gt;I recently wanted to create an animated PNG, but macOS does not include any built in tools to combine multiple &lt;a href="https://en.wikipedia.org/wiki/PNG" rel="external"&gt;PNG&lt;/a&gt;s into an &lt;a href="https://en.wikipedia.org/wiki/APNG" rel="external"&gt;APNG&lt;/a&gt; file. Here’s an option using &lt;strong&gt;Python&lt;/strong&gt; source code.&lt;/p&gt;</description></item><item><title>File Date Created = Photo / video metadata</title><link>https://myByways.com/post/file-date-created-to-photo-video-metadata/</link><pubDate>Sun, 04 Jun 2023 00:00:00 +0000</pubDate><guid>https://myByways.com/post/file-date-created-to-photo-video-metadata/</guid><description>&lt;p&gt;When I export photos or videos from &lt;strong&gt;Photos.app&lt;/strong&gt;, I want the file’s &lt;strong&gt;Created Date&lt;/strong&gt; (&lt;strong&gt;Created Date&lt;/strong&gt; in Finder) to be the time the photo or video was taken. Alas, this is not the way Photos works, and setting the date turned out to be more challenging than expected.&lt;/p&gt;</description></item><item><title>myByways Simple-SD v1.1 Python script using Safetensors</title><link>https://myByways.com/post/mybyways-simple-sd-v1-1-python-script-using-safetensors/</link><pubDate>Tue, 24 Jan 2023 00:00:00 +0000</pubDate><guid>https://myByways.com/post/mybyways-simple-sd-v1-1-python-script-using-safetensors/</guid><description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://huggingface.co/johnslegers/epic-diffusion" rel="external"&gt;Epic Diffusion&lt;/a&gt;&lt;/strong&gt; recently came to my attention, a high-quality merge of various models by John Slegers: “Epîc Diffusion is a general purpose model based on Stable Diffusion 1.x intended to replace the official SD releases as your default model. It is focused on providing high quality output in a wide range of different styles&amp;hellip;” Figured I’d give it a spin.&lt;/p&gt;</description></item><item><title>Fast Stable Diffusion using Core ML on M1</title><link>https://myByways.com/post/fast-stable-diffusion-using-core-ml-on-m1/</link><pubDate>Sun, 18 Dec 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/fast-stable-diffusion-using-core-ml-on-m1/</guid><description>&lt;p&gt;Recently (around 14 December 2022), Apple’s &lt;strong&gt;Machine Learning Research&lt;/strong&gt; team published &lt;a href="https://machinelearning.apple.com/research/stable-diffusion-coreml-apple-silicon" rel="external"&gt;“Stable Diffusion with Core ML on Apple Silicon”&lt;/a&gt; with Python and Swift source code optimized for Apple Silicon (M1/M2) on Github &lt;a href="https://github.com/apple/ml-stable-diffusion" rel="external"&gt;apple/ml-stable-diffusion&lt;/a&gt;. Here I’m trying it out on a MacBook (though the code also works on iPhones and iPads)&amp;hellip;&lt;/p&gt;</description></item><item><title>myByways Simple-SD v1.0 Python script</title><link>https://myByways.com/post/mybyways-simple-sd-python-script/</link><pubDate>Sun, 09 Oct 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/mybyways-simple-sd-python-script/</guid><description>&lt;p&gt;I refactored my &lt;a href="https://myByways.com/post/adding-clipseg-automatic-masking-to-stable-diffusion"&gt;previous &lt;strong&gt;Stable Diffusion&lt;/strong&gt; code&lt;/a&gt;, to clean up, OO it a little, and add new features like tiling, upscaling, PNG metadata. As I mentioned before, I don’t understand AI/ML&amp;hellip; but I do understand programming! So here is my new, more elegant &lt;strong&gt;Simple-SD v1.0&lt;/strong&gt; Python script.&lt;/p&gt;</description></item><item><title>Adding CLIPSeg automatic masking to Stable Diffusion</title><link>https://myByways.com/post/adding-clipseg-automatic-masking-to-stable-diffusion/</link><pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/adding-clipseg-automatic-masking-to-stable-diffusion/</guid><description>&lt;p&gt;I have more ideas for &lt;strong&gt;Stable Diffusion&lt;/strong&gt;. My nights and weekends are consumed! This time: For inpainting, why create a mask image manually, when A.I. can automatically build a mask from a text prompt? Someone much smarter has already &lt;a href="https://arxiv.org/abs/2112.10003" rel="external"&gt;published a paper (arXiv:2112.10003 [cs.CV])&lt;/a&gt;, with source code, to do just this!&lt;/p&gt;</description></item><item><title>Stable Diffusion script with inpainting mask</title><link>https://myByways.com/post/stable-diffusion-script-with-in-painting-mask/</link><pubDate>Mon, 26 Sep 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/stable-diffusion-script-with-in-painting-mask/</guid><description>&lt;p&gt;More &lt;strong&gt;Stable Diffusion!&lt;/strong&gt; This time &lt;em&gt;attempting&lt;/em&gt; to add inpainting / masking based on my previous code, to merge both &lt;code&gt;txt2img.py&lt;/code&gt; and &lt;code&gt;img2img.py&lt;/code&gt; capabilities, disregarding the out-of-box &lt;code&gt;inpainting.py&lt;/code&gt; code, which does not have parameters for positive or negative prompts. Keyword being &lt;em&gt;attempting&lt;/em&gt;&amp;hellip;&lt;/p&gt;</description></item><item><title>My simplified Stable Diffusion Python script</title><link>https://myByways.com/post/my-simplified-stable-diffusion-python-script/</link><pubDate>Wed, 21 Sep 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/my-simplified-stable-diffusion-python-script/</guid><description>&lt;p&gt;I’ve been playing around with the &lt;a href="https://github.com/CompVis/stable-diffusion" rel="external"&gt;Stable Diffusion&lt;/a&gt; scripts a little (to be exact, &lt;a href="https://github.com/bfirsh/stable-diffusion" rel="external"&gt;Ben Firshman’s version&lt;/a&gt;). To help me understand the script, I decided to re-write it the way I prefer to use it&amp;hellip; either breaking or optimizing it in the process :P&lt;/p&gt;</description></item><item><title>Stable Diffusion image-to-image mode</title><link>https://myByways.com/post/stable-diffusion-image-to-image-mode/</link><pubDate>Sat, 17 Sep 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/stable-diffusion-image-to-image-mode/</guid><description>&lt;p&gt;Following from my previous post, &lt;a href="https://myByways.com/post/ai-generated-images-with-stable-diffusion-on-an-m1-mac"&gt;AI-generated images with Stable Diffusion on an M1 mac&lt;/a&gt;: This time, using the image-to-image script, which takes an input “seed” image, in addition to the text prompt as inputs. In this case the model will use the shapes and colors in the input image as a base for the output AI-generated image.&lt;/p&gt;</description></item><item><title>AI-generated images with Stable Diffusion on an M1 mac</title><link>https://myByways.com/post/ai-generated-images-with-stable-diffusion-on-an-m1-mac/</link><pubDate>Fri, 16 Sep 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/ai-generated-images-with-stable-diffusion-on-an-m1-mac/</guid><description>&lt;p&gt;There has been a lot of buzz about &lt;strong&gt;Stable Diffusion&lt;/strong&gt; for text-to-image synthesis, which saw its Public Release around 22 Aug 22. You can read more on the &lt;a href="https://stability.ai/blog/stable-diffusion-public-release" rel="external"&gt;Stability.AI blog&lt;/a&gt; and try it at &lt;a href="https://huggingface.co/spaces/stabilityai/stable-diffusion" rel="external"&gt;Hugging Face&lt;/a&gt;. What’s groundbreaking is is that is open source, with a pre-trained downloadable model and modest system requirements, so anyone can try it on their own computer&amp;hellip; anyone&amp;hellip; like me!&lt;/p&gt;</description></item><item><title>Running GFPGAN Face Restoration in a container</title><link>https://myByways.com/post/running-gfpgan-face-restoration-in-a-container/</link><pubDate>Mon, 01 Aug 2022 00:00:00 +0000</pubDate><guid>https://myByways.com/post/running-gfpgan-face-restoration-in-a-container/</guid><description>&lt;p&gt;Almost a year ago, Tencent researchers released their &lt;a href="https://github.com/TencentARC/GFPGAN" rel="external"&gt;GFPGAN Face Restoration&lt;/a&gt;, an AI model which is trained specifically on faces, to better upscale and restore details in low-resolution or damaged portrait photos. I thought I’d give it a whirl.&lt;/p&gt;</description></item><item><title>Migrating from bash shell scripts to Python</title><link>https://myByways.com/post/migrating-from-bash-shell-scripts-to-python/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +0000</pubDate><guid>https://myByways.com/post/migrating-from-bash-shell-scripts-to-python/</guid><description>&lt;p&gt;I recently wanted to migrate from a &lt;strong&gt;Bash 3&lt;/strong&gt; shell script to &lt;strong&gt;Python 3&lt;/strong&gt;. This is nothing but a brain dump comparing a few bits and bobs.&lt;/p&gt;</description></item></channel></rss>