• Making the Perfect Profile Image with Stable Diffusion & Dreambooth.

    Overview

    This will help you create a Stable Diffusion Dreambooth model that will use textual inputs to create imagery of you / whoever you choose to model. The process is unbelievable fun & weird & narcissistic.

    Stable Diffusion is a system allowing you to create detailed images based on text descriptions.

    Dreambooth allows for text-to-image generation with only a few sample images.

    Prior Art

    I went down this path using Mathowie’s blog post + AItreprenuer’s video.

    Steps

    • Get an API key from Hugging Face
      You’ll need to download the Dreambooth model.

    • Pay for some Google Colab Compute Units
      Get $9.99 / pay-as-you-go

    • Copy this Colab Python Notebook
    • Pick out 20-30 pictures of yourself. Make sure you’re the only one in the photo.
    • Using birme.net,
      • Crop each photo to 512×512 pixels
      • Save your photos using a name that has never been used anywhere. This is how you’ll refer to yourself textually when describing your photos. I used jbdb_1.jpg, jbdb_2.jpg, etc.


    • Go through the notebook’s steps & train your model. This will take about 45 minutes & will save a ~2gig model into your Google Drive.
    • Once that’s done, you’ll be able to start up the notebook whenever you like & create images.

      I’ve kept a list of the textual prompts that have resulted in interesting outputs here.

      An alternative – if you have a healthy GPU at home – is to download to model you generated on Colab from Google Drive and generate images at home. The benefits to this are:
      • You won’t incur startup wait times / bootstrapping when starting Stable Diffusion via Colab.
      • You don’t need to keep a 2 gig model in Google Drive
      • Stable Diffusion UI has a bunch of extra features you can play with.
      • You can quickly swap between generated models.

    Tips

    • When you don’t like how an image was rendered, determine what you don’t like about the image (eg “Too anime”), and then use “anime” in the negative prompt.
    • GFPGAN is a feature in the desktop version of Stable Diffusion that “corrects faces”. While it does correct faces, it also feels like it takes something away from the distinguishing features of a face.
    • Generate a series of images to get the gist of types of imagery you’ll create.


  • We Learned Today

    TIL is an initialism commonly used on the internet, meaning “Today I Learned”. I usually find myself learning something new whenever I stumble across these little nuggets of wisdom.

    To see them more often, I built a Twitter bot, @welearnedtoday that retweets TIL tweets seen in the wild.

    I hope it helps you learn something new today.

    Related

  • Minivan Media Player

    Raspberry Pi + SSD + HDMI + Power Supply

    We recently purchased a Toyota Sienna, and it came with an in-car media system. This is my solution to provide entertainment to the car.

    Limiting Factors

    • We’re an iOS household, so an Android solution isn’t ideal.
    • We don’t pay for the car’s cellular connection.

    Research

    Toyota Sienna Media Specs

    2022 Toyota Sienna

    Screen Size: 11.6” screen (10.1 x 5.7)
    Resolution: 126PPI / 1,273 x 718

    The van has an HDMI port and a 110v plug.

    Attempted Entertainment Solutions

    • DLNA / Miracast
      You can cast media to the device via DLNA, but I haven’t found an iOS application that does this well. Gallery Cast let me cast from an Android device, but I was unable to change the aspect ratio of the phone, leaving significant letterboxing / distortion.
    • iOS – Lightning-to-HDMI dongle
      Works well, but I only have one phone & need it for GPS / CarPlay.
    • Android – USB-C hub to HDMI
      Works
    • Amazon Fire Tablet
      Does not work
    • Netflix
      Doesn’t work. Guessing it’s an HDCP issue?
    • Nintendo Switch
      Works great

    Parts

    Setup

    LibreElec is a lightweight operating system designed to let Kodi run in a dedicated fashion on less powerful hardware.

    Note: When attempting to write to the microSD card with the LibreELEC application from MacOS Monterrey, I ran into issues.

    2022-04-06 14:14:34.606 LibreELEC USB-SD Creator[13702:6746712] XType: com.apple.fonts is not accessible.
    2022-04-06 14:14:34.606 LibreELEC USB-SD Creator[13702:6746712] XType: XTFontStaticRegistry is enabled.
    PasteBoard: Error creating pasteboard: com.apple.pasteboard.clipboard [-4960]
    PasteBoard: Error creating pasteboard: com.apple.pasteboard.find [-4960]
    2022-04-06 14:14:35.529 LibreELEC USB-SD Creator[13702:6746712] The application with bundle ID com.apple.ScriptEditor.id.LibreELEC is running setugid(), which is not allowed. Exiting.
    

    As a workaround, I found archive of all images: https://archive.libreelec.tv/ & snagged the latest RPi4 image at the current time.

    Getting Content Onto the Device

    Via the Kodi administration screen, you can enable an SMB mount. This will enable you to mount the device as a network drive for copying files over.

    If you’re a bit-miser, you can first compress your movies to the exact size needed in the car to make sure you’re not wasting any space. I use ffmpeg to downsample, saving the files over the SMB mount to the Pi.

    ffmpeg -i "./VIDEO_NAME.mkv" -vf scale=1274:718 "/media/kodi-videos/VIDEO_NAME.mp4"

    Controlling the Device

    • Use a mouse
      Tired: Bluetooth mice whose batteries run out.
      Wired: Always-dependable, old-fashioned wired mice.

      Kodi uses an on-screen keyboard, so a mouse is all you should need for any action you wish to take.
    • Sybu for Kodi (iOS)
      I’m still getting the hang of this application. My hope was that I could fully control Kodi from the front seat of the van.

      At present, I’ve only had luck in using the mobile application as a dumb mouse of sorts, selecting on-screen items, which requires me to be in the back seat.

      The other caveat for using this application is that you need to figure out how to setup wifi for your phone to talk to the Pi.

    Setting up Wifi

    Using your home wifi / ethernet works great for getting content onto the device. If you want to use the mobile application to interact with Kodi, you’ll need to find a way to wireless connect to it.

    I’m still working through setting up wifi on the device and will update as I try new potential solutions. Here’s what I’ve tried so far:

    Using the In-Car Wifi

    In-car cellular wifi is one of the dumber features recently released with cars. We chose not to extend the service after the free month ended, but I was curious if I could still hijack the service for use in communicating between devices in the car. Unfortunately, it’s a captive portal, and devices are unable to even connect to the access point unless they’ve paid for service.

    Using the Raspberry Pi as an access point

    Kodi has an option to use the Raspberry Pi as an access point. This allows you to control the application via the mobile app, but has the downside of connecting you to a wifi network that does not have internet connectivity. By default, your phone will continue to try & automatically connect to the network, which will prevent your phone from doing anything requiring an internet connection.

    Using the Phone’s Shared Wifi

    Kodi doesn’t detect my iPhone’s Personal Hotspot. Doesn’t show up in the list of available networks.

    TODO: Using the Phone’s Shared Wifi by modifying wpa_supplicant via Shell?
    That’s not going to work. LibreELEC uses Connman (details) (more details on the issue)

    TODOs

    • Truncate cables
    • Clean up empty menus in Kodi