Type | |
Stats | 866 |
Reviews | (37) |
Published | Jun 15, 2024 |
Base Model | |
Hash | AutoV2 8B660D393A |
credits to Thyri
Perturbed Version of SD3 using script (replace input and output location)
download sd3 from huggingface
put script in a .py (replace input with sd3 model location and output location with where and what you want to name it). modify 0.01 to how much you want it to be perturbed (0.01 = 1%)
execute the .py using "python your_py_script.py" (maybe you need to activate your virtual environment)
import torch
from safetensors.torch import load_file, save_file
# Load the safetensors model
model = load_file('__INPUT LOCATION__')
# Extract the keys and tensors
keys = model.keys()
dic = {key: model[key] for key in keys}
# Define parts to filter
parts = ['diffusion_model']
count = 0
# Perturb the specified parts
for k in keys:
if all(part in k for part in parts):
v = dic[k]
print(f'{k}: {v.std()}')
dic[k] += torch.normal(torch.zeros_like(v), v.std() * 0.01)
count += 1
print(f'Total perturbed tensors: {count}')
# Save the perturbed model
save_file(dic, '__OUTPUT LOCATION__')