Create test.py
Browse files
test.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import safetensors.torch
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# Function to inspect data types in a safetensors file
|
| 5 |
+
def inspect_safetensors_dtype(file_path):
|
| 6 |
+
print(f"Inspecting: {file_path}")
|
| 7 |
+
tensors = safetensors.torch.load_file(file_path)
|
| 8 |
+
for key, tensor in tensors.items():
|
| 9 |
+
print(f"Key: {key}, Data Type: {tensor.dtype}")
|
| 10 |
+
print("\n")
|
| 11 |
+
|
| 12 |
+
# Get all safetensors files in the current directory
|
| 13 |
+
safetensors_files = [f for f in os.listdir() if f.endswith('.safetensors')]
|
| 14 |
+
|
| 15 |
+
# Inspect each safetensors file
|
| 16 |
+
for safetensors_file in safetensors_files:
|
| 17 |
+
inspect_safetensors_dtype(safetensors_file)
|