Skip to content

Commit 609df3c

Browse files
committed
add progress bar
1 parent 981bd44 commit 609df3c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gguf-py/scripts/gguf-new-metadata.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88

99
import numpy as np
10+
from tqdm import tqdm
1011
from typing import Any, Sequence, NamedTuple
1112

1213
# Necessary to load the local gguf package
@@ -113,17 +114,23 @@ def copy_with_new_metadata(reader: gguf.GGUFReader, writer: gguf.GGUFWriter, new
113114
writer.add_key(key)
114115
writer.add_val(val.value, val.type)
115116

117+
total_bytes = 0
118+
116119
for tensor in reader.tensors:
120+
total_bytes += tensor.n_bytes
117121
# Dimensions are written in reverse order, so flip them first
118122
shape = np.flipud(tensor.shape).tolist()
119123
writer.add_tensor_info(tensor.name, shape, tensor.data.dtype, tensor.data.nbytes, tensor.tensor_type)
120124

125+
bar = tqdm(desc="Writing", total=total_bytes, unit="byte", unit_scale=True)
126+
121127
writer.write_header_to_file()
122128
writer.write_kv_data_to_file()
123129
writer.write_ti_data_to_file()
124130

125131
for tensor in reader.tensors:
126132
writer.write_tensor_data(tensor.data)
133+
bar.update(tensor.n_bytes)
127134

128135
writer.close()
129136

0 commit comments

Comments
 (0)