From 8c9dd95d5530d86dfcdf0d8548a9c31f2b1e0e40 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 19 Feb 2023 01:48:23 -0300 Subject: [PATCH] Print the softprompt metadata when it is loaded --- server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server.py b/server.py index 09e79c02..04b2c7e3 100644 --- a/server.py +++ b/server.py @@ -173,7 +173,19 @@ def load_soft_prompt(name): else: with zipfile.ZipFile(Path(f'softprompts/{name}.zip')) as zf: zf.extract('tensor.npy') + zf.extract('meta.json') + j = json.loads(open('meta.json', 'r').read()) + print(f"\nLoading the softprompt \"{name}\".") + for field in j: + if field != 'name': + if type(j[field]) is list: + print(f"{field}: {', '.join(j[field])}") + else: + print(f"{field}: {j[field]}") + print() tensor = np.load('tensor.npy') + Path('tensor.npy').unlink() + Path('meta.json').unlink() tensor = torch.Tensor(tensor).to(device=model.device, dtype=model.dtype) tensor = torch.reshape(tensor, (1, tensor.shape[0], tensor.shape[1])) @@ -187,6 +199,7 @@ def upload_soft_prompt(file): zf.extract('meta.json') j = json.loads(open('meta.json', 'r').read()) name = j['name'] + Path('meta.json').unlink() with open(Path(f'softprompts/{name}.zip'), 'wb') as f: f.write(file)