Using Local AI On The Command Line To Rename Images (And More)

We all have a folder full of images whose filenames resemble line noise. How about renaming those images with the help of a local LLM (large language model) executable on the command line? All that and more is showcased on [Justine Tunney]’s bash one-liners for LLMs, a showcase aimed at giving folks ideas and guidance on using a local (and private) LLM to do actual, useful work.

This is built out from the recent llamafile project, which turns LLMs into single-file executables. This not only makes them more portable and easier to distribute, but the executables are perfectly capable of being called from the command line and sending to standard output like any other UNIX tool. It’s simpler to version control the embedded LLM weights (and therefore their behavior) when it’s all part of the same file as well.

One such tool (the multi-modal LLaVA) is capable of interpreting image content. As an example, we can point it to a local image of the Jolly Wrencher logo using the following command:

llava-v1.5-7b-q4-main.llamafile --image logo.jpg --temp 0 -e -p '### User: The image has...\n### Assistant:'

Which produces the following response:

The image has a black background with a white skull and crossbones symbol.

With a different prompt (“What do you see?” instead of “The image has…”) the LLM even picks out the wrenches, but one can already see that the right pieces exist to do some useful work.

Check out [Justine]’s rename-pictures.sh script, which cleverly evaluates image filenames. If an image’s given filename already looks like readable English (also a job for a local LLM) the image is left alone. Otherwise, the picture is fed to an LLM whose output guides the generation of a new short and descriptive English filename in lowercase, with underscores for spaces.

What about the fact that LLM output isn’t entirely predictable? That’s easy to deal with. [Justine] suggests always calling these tools with the --temp 0 parameter. Setting the temperature to zero makes the model deterministic, ensuring that a same input always yields the same output.

There’s more neat examples on the Bash One-Liners for LLMs that demonstrate different ways to use a local LLM that lives in a single-file executable, so be sure to give it a look and see if you get any new ideas. After all, we have previously shown how automating tasks is almost always worth the time invested.

A Guide For Heat-Treating Steel At Home

A lot of colloquial words that we might use when describing something’s durability take on extremely specific meanings when a materials scientist or blacksmith uses them. Things like “strength”, “toughness”, “hardness”, and “resilience” all have different meanings when working in a laboratory or industrial setting than most people might otherwise think.

For the beginner metalworker, this can be a little bit confusing at first but some hands-on practice will help. To that end, this beginner lesson in heat-treating steel from [Blondihacks] demonstrates why it can be beneficial to trade some of the metal’s toughness for improved hardness and just how to accomplish it on your own.

The first part of the lesson is to make sure the steel is high-carbon steel, since most other steels aren’t able to be heat treated. It will also have a specific method for its quenching, either in oil, water, or some other medium. But beyond that the only other thing required for this process is a torch of some sort. [Blondihacks] is using a MAP-Pro torch to get the steel up to temperature, which is recognizable when it turns a specific orange color. From there all that’s needed is to quench the hot metal in whatever fluid is called for. At this point the metal can also be tempered, which restores some of its toughness while maintaining a certain amount of hardness.

While the process doesn’t require specialized tools, [Blondihacks] does have a hardness tester, a fairly expensive piece of instrumentation that measures how deeply the metal can be indented by a force. By measuring the size of the indentation made by the tool, the hardness can be determined. As it’s many thousands of dollars this is mostly for demonstration and not necessary for most of us, but does go a long way to demonstrate the effectiveness of heat treating and tempering in an otherwise simple environment. If you’re looking for excuses to start heat treating and tempering metal, here’s a great project which creates a knife nearly from scratch.

Continue reading “A Guide For Heat-Treating Steel At Home”

Second Life UPS Mark II: A UPS For Low-Voltage DC Applications

When you have a whole stack of devices and appliances that all have an AC to DC adapter and which you’d like to put on an uninterruptable power supply (UPS), you could do the obvious thing and get an off-the-shelf UPS with myriad AC outputs. In the case of a 19″ rack this means wrangling a power strip or two and any combination of differently sized AC/DC adapters into the rack, with questionable efficiency and waste heat dumped into the rack. This is where a DC-only UPS like [Maciej Grela]’s Second Life UPS Mark II provides an interesting alternative.

At its core it’s a pretty simple concept: A single 400Watt power supply handles the AC/DC conversion from mains to 24 VDC, which feeds the battery charger as well as the outputs. These outputs include 5 VDC, 12 VDC and Vrail, with the latter being either the output from the PSU, or the battery voltage. In case of AC power failure, an LT4416 dual power path controller handles the switch-over from the PSU output to the internal batteries. In the article, [Maciej] covers how the buck modules for the 12 & 5 VDC rails were sized, along with the conversion of an old rack-mounted network switch into a UPS. Continue reading “Second Life UPS Mark II: A UPS For Low-Voltage DC Applications”

Hacker Tactic: Internal ESD Diode Probing

Humans are walking high voltage generators, due to all the friction with our surroundings, wide variety of synthetic clothes, and the overall ever-present static charges. Our electronics are sensitive to electrostatic discharge (ESD), and often they’re sensitive in a way most infuriating – causing spurious errors and lockups. Is there a wacky error in your design that will repeat in the next batch, or did you just accidentally zap a GPIO? You wouldn’t know until you meticulously check the design, or maybe it’s possible for you to grab another board.

Thankfully, in modern-day Western climates and with modern tech, you are not likely to encounter ESD-caused problems, but they were way more prominent back in the day. For instance, older hackers will have stories of how FETs were more sensitive, and touching the gate pin mindlessly could kill the FET you’re working with. Now, we’ve fixed this problem, in large part because we have added ESD-protective diodes inside the active components most affected.

These diodes don’t just help against ESD – they’re a general safety measure for protecting IC and transistor pins, and they also might help avoid damaging IC pins if you mix. They also might lead to funny and unexpected results, like parts of your circuit powering when you don’t expect them to! However, there’s an awesome thing that not that many hackers know — they let you debug and repair your circuits in a way you might not have imagined.

Continue reading “Hacker Tactic: Internal ESD Diode Probing”

How To Talk To Your Scope

It used to be only high-end test equipment that had some sort of remote control port. These days, though, they are quite common. Historically, test gear used IEEE-488 (also known as GPIB or, from the originator, HPIB). But today, your device will likely talk over a USB port, a serial port, or a LAN connection. You’d think that every instrument had unique quirks, and controlling it would be nothing like controlling another piece of gear, especially one from another company. That would be half right. Each vendor and even model indeed has its unique command language. There has been a significant effort to standardize some aspects of test instrument control, and you can quickly write code to control things on any platform using many different programming languages. In a few posts, I will show you just how easy it can be.

The key is to use VISA. This protocol is defined by the IVI Foundation that lets you talk to instruments regardless of how they communicate. You do have to build an address that tells the VISA library how to find your device. For example: “TCPIP::192.168.1.92::INSTR.” But once you have that, it is easy to talk to any instrument anywhere.

I say that thinking it is a problem is half right because talking to the box is one task of the two you need to complete. The other is what to say to the box and what it will say back to you. There are a few standards in this area, but this is where you get into problems. Continue reading “How To Talk To Your Scope”

Lessons Learned: Plastic Injection Molding For Products

Injection molding is one of the technologies that makes the world go round. But what does it actually look like to go through the whole process to get a part made? [Achim Haug] wrote up a blog post that does a fantastic job of explaining what to expect when getting plastic enclosures injection molded in China.

These air quality monitors required a two-part enclosure.

Injection molding a part requires making a custom mold, which is then used by an injection molding machine in a shop to crank out parts. These are two separate jobs, but in China the typical business model is for a supplier to quote a price for both the mold as well as the part production. [Achim] describes not only what navigating that whole process was like, but also goes into detail on what important lessons were learned and shares important tips.

One of the biggest takeaways is to design the part with injection molding in mind right from the start. That means things like avoiding undercuts and changes in part thickness, as well as thinking about where the inevitable mold line will end up.

[Achim] found that hiring a been-there-done-that mold expert as a consultant to review things was a huge help, and well worth the money. As with any serious engineering undertaking, apparently small features or changes can have an outsized impact on costs, and an expert can recognize and navigate those.

In the end, [Achim] says that getting their air quality monitor enclosures injection molded was a great experience and they are very happy with the results, so long as one is willing to put the work in up front. Once the mold has been made, downstream changes can be very costly to make.

[Achim]’s beginning-to-end overview is bound to be useful to anyone looking to actually navigate the process, and we have a few other resources to point you to if you’re curious to learn more. There are basic design concerns to keep in mind when designing parts to make moving to injection molding easier. Some injection molding techniques have even proven useful for 3D printing, such as using crush ribs to accommodate inserted hardware like bearings. Finally, shadow lines can help give an enclosure a consistent look, while helping to conceal mold lines.

Making A Concrete Sign

While paging through the feed a few days ago our attention was caught by something a little away from the ordinary in Hackaday terms, a DIY video about creating cast concrete signage from [Proper DIY] which we’ve placed below the break. A deceptively easy-looking mould-making process has a few tricks that  will make the difference between a hard-wearing sign that lasts for years, and a lump of concrete.

So, to make a cast concrete sign, you throw together a mould with some letters, and chuck in some concrete? Not so fast, because the key appears to be preparation, and ensuring that there are no 90-degree corners on the mould parts. The letters are carefully shaped and sealed with varnish before being attached to the mould with silicone adhesive, and all the corners are beveled. Finally a light oil is used as a release agent, and hefty vibration takes care of any air bubbles.

The result is a set of signs, but we can see these techniques finding uses outside signage. For example, how about casting using a 3D printed mould?

Continue reading “Making A Concrete Sign”