Upload 3 files
Browse files- convert_url_to_diffusers_flux_gr.py +5 -2
- requirements.txt +3 -9
convert_url_to_diffusers_flux_gr.py
CHANGED
@@ -57,9 +57,11 @@ def clear_sd(sd: dict):
|
|
57 |
gc.collect()
|
58 |
|
59 |
def clone_sd(sd: dict):
|
|
|
60 |
print("Cloning state dict.")
|
61 |
for k in list(sd.keys()):
|
62 |
-
sd[k] = sd.pop(k)
|
|
|
63 |
torch.cuda.empty_cache()
|
64 |
gc.collect()
|
65 |
|
@@ -384,7 +386,7 @@ def read_safetensors_metadata(path):
|
|
384 |
header_json = f.read(header_size).decode('utf-8')
|
385 |
header = json.loads(header_json)
|
386 |
metadata = header.get('__metadata__', {})
|
387 |
-
return metadata
|
388 |
|
389 |
def normalize_key(k: str):
|
390 |
return k.replace("vae.", "").replace("model.diffusion_model.", "")\
|
@@ -438,6 +440,7 @@ with torch.no_grad():
|
|
438 |
progress(0.5, desc=f"Saving FLUX.1 {name} to: {path}")
|
439 |
print(f"Saving FLUX.1 {name} to: {path}")
|
440 |
if metadata is not None:
|
|
|
441 |
save_torch_state_dict(state_dict=sd, save_directory=path,
|
442 |
filename_pattern=pattern, max_shard_size=size, metadata=metadata)
|
443 |
else:
|
|
|
57 |
gc.collect()
|
58 |
|
59 |
def clone_sd(sd: dict):
|
60 |
+
from copy import deepcopy
|
61 |
print("Cloning state dict.")
|
62 |
for k in list(sd.keys()):
|
63 |
+
sd[k] = deepcopy(sd.pop(k))
|
64 |
+
#sd[k] = sd.pop(k).detach().clone().to(device="cpu")
|
65 |
torch.cuda.empty_cache()
|
66 |
gc.collect()
|
67 |
|
|
|
386 |
header_json = f.read(header_size).decode('utf-8')
|
387 |
header = json.loads(header_json)
|
388 |
metadata = header.get('__metadata__', {})
|
389 |
+
return metadata.copy()
|
390 |
|
391 |
def normalize_key(k: str):
|
392 |
return k.replace("vae.", "").replace("model.diffusion_model.", "")\
|
|
|
440 |
progress(0.5, desc=f"Saving FLUX.1 {name} to: {path}")
|
441 |
print(f"Saving FLUX.1 {name} to: {path}")
|
442 |
if metadata is not None:
|
443 |
+
progress(0.5, desc=f"Saving FLUX.1 {name} metadata to: {path}")
|
444 |
save_torch_state_dict(state_dict=sd, save_directory=path,
|
445 |
filename_pattern=pattern, max_shard_size=size, metadata=metadata)
|
446 |
else:
|
requirements.txt
CHANGED
@@ -1,15 +1,9 @@
|
|
1 |
-
|
2 |
safetensors
|
3 |
-
git+https://github.com/huggingface/
|
4 |
-
git+https://github.com/huggingface/accelerate
|
5 |
-
git+https://github.com/huggingface/diffusers
|
6 |
-
git+https://github.com/huggingface/peft
|
7 |
optimum-quanto
|
8 |
sentencepiece
|
9 |
-
|
10 |
-
torchaudio
|
11 |
-
torchvision
|
12 |
-
pytorch_lightning
|
13 |
aria2
|
14 |
gdown
|
15 |
gguf>=0.9.1
|
|
|
1 |
+
torch
|
2 |
safetensors
|
3 |
+
git+https://github.com/huggingface/huggingface_hub
|
|
|
|
|
|
|
4 |
optimum-quanto
|
5 |
sentencepiece
|
6 |
+
git+https://github.com/Lightning-AI/pytorch-lightning
|
|
|
|
|
|
|
7 |
aria2
|
8 |
gdown
|
9 |
gguf>=0.9.1
|