I made a little too that I've decided to release for everyone. stinfo
is a command-line utility designed for people working with .safetensors
files. Available now on GitHub, stinfo
makes it easy to have a peek at the metadata embedded in .safetensors
files.
Features
Verbose Mode (
-v
): Prints the size of the JSON header.Pretty-Print (
-p
): Formats the JSON output with proper indentation.Metadata Extraction (
-m
): Extracts and prints only the__metadata__
object.
How It Works
The .safetensors
file format begins with an 8-byte length prefix for the JSON metadata, followed by the metadata itself. stinfo
reads this prefix to determine the length, then extracts and optionally formats the JSON data for easy viewing.
Usage
stinfo [options] <filename>
Options:
-v
: Verbose output, prints the JSON header size.-p
: Pretty-print the JSON output with indentation.-m
: Print only the__metadata__
object.--?
: Show help message and exit.
Example Commands
Print the JSON metadata with verbose output:
stinfo -v example.safetensors
Pretty-print the JSON metadata:
stinfo -p example.safetensors
Print only the
__metadata__
object:stinfo -m example.safetensors
Building the Program
To compile stinfo
, you can use GCC:
gcc stinfo.c -o stinfo
For Visual Studio users, make sure to set the build configuration to Release:
Open a new project as a Console App in Visual Studio. Call it stinfo.
Open the code on Github. Copy and Paste the code over the "hello world" code in Visual Studio.
Go to Build > Configuration Manager.
Set Active Solution Configuration to Release.
Close the Configuration Manager.
Get the Code
You can get it on Github right here .
Have fun!