From d8ddacde38598f953fd4c7336ad72ac409c6d688 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Mon, 9 Jun 2025 11:26:24 +0800 Subject: [PATCH] Remove 'folder' field from model metadata before saving to file. See #211 --- py/routes/example_images_routes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/py/routes/example_images_routes.py b/py/routes/example_images_routes.py index 231abcfa..585144f5 100644 --- a/py/routes/example_images_routes.py +++ b/py/routes/example_images_routes.py @@ -439,9 +439,13 @@ class ExampleImagesRoutes: base_path = os.path.splitext(file_path)[0] # Remove .safetensors extension metadata_path = f"{base_path}.metadata.json" try: - # Write the metadata to file + # Create a copy of the model data without the 'folder' field + model_copy = model.copy() + model_copy.pop('folder', None) + + # Write the metadata to file without the folder field with open(metadata_path, 'w', encoding='utf-8') as f: - json.dump(model, f, indent=2, ensure_ascii=False) + json.dump(model_copy, f, indent=2, ensure_ascii=False) logger.info(f"Saved metadata to {metadata_path}") except Exception as e: logger.error(f"Failed to save metadata to {metadata_path}: {str(e)}")