diff --git a/tasks/report_bundle.zip b/tasks/report_bundle.zip new file mode 100644 index 00000000..f4bf0600 Binary files /dev/null and b/tasks/report_bundle.zip differ diff --git a/tasks/report_bundle/README.txt b/tasks/report_bundle/README.txt new file mode 100644 index 00000000..fbf72d5a --- /dev/null +++ b/tasks/report_bundle/README.txt @@ -0,0 +1,13 @@ +# Report Bundle + +Hi! +This report includes everything you need to review the image generation results. + +What’s inside: +- `results.csv` — a table with image scores and file paths +- `config.json` — the exact settings used during generation (models, prompts, etc.) +- Grid images — labeled previews of the outputs + +Feel free to explore or reuse any part of it. Let me know if anything’s missing! + +— Lial diff --git a/tasks/report_bundle/config.json b/tasks/report_bundle/config.json new file mode 100644 index 00000000..d15ca217 --- /dev/null +++ b/tasks/report_bundle/config.json @@ -0,0 +1,6 @@ +{ + "model": "stable-diffusion", + "seed": 42, + "steps": 30, + "sampler": "Euler" +} diff --git a/tasks/report_bundle/generate_report.py b/tasks/report_bundle/generate_report.py new file mode 100644 index 00000000..5cbbe302 --- /dev/null +++ b/tasks/report_bundle/generate_report.py @@ -0,0 +1,56 @@ +""" + +This script (generate_report.py) generates a ZIP archive... + +This script validates the presence and structure of required files (CSV, config, README), +checks for missing images listed in results.csv, and packages all content—including the +'grids' folder—into a single ZIP file named report.zip. + +Used for reporting and archiving results of image-based evaluations. +""" + +import os +import csv +import zipfile + +RESULTS_FILE = 'results.csv' +CONFIG_FILE = 'config.json' +GRIDS_DIR = 'grids' +README_FILE = 'README.txt' +OUTPUT_ZIP = 'report.zip' + + +required_files = [RESULTS_FILE, CONFIG_FILE, README_FILE] +for file in required_files: + if not os.path.exists(file): + raise FileNotFoundError(f"{file} not found!") + +if not os.path.isdir(GRIDS_DIR): + raise FileNotFoundError("Grids directory not found!") + + +required_columns = {'id', 'image_path', 'score'} +with open(RESULTS_FILE, newline='') as csvfile: + reader = csv.DictReader(csvfile) + if not required_columns.issubset(reader.fieldnames): + raise ValueError(f"CSV missing required columns: {required_columns - set(reader.fieldnames)}") + + for row in reader: + if not os.path.exists(row['image_path']): + raise FileNotFoundError(f"Image file not found: {row['image_path']}") + +with zipfile.ZipFile(OUTPUT_ZIP, 'w', compression=zipfile.ZIP_DEFLATED) as zf: + zf.write(RESULTS_FILE) + zf.write(CONFIG_FILE) + zf.write(README_FILE) + + for foldername, subfolders, filenames in os.walk(GRIDS_DIR): + for filename in filenames: + file_path = os.path.join(foldername, filename) + arcname = os.path.relpath(file_path, start='.') + zf.write(file_path, arcname=arcname) + + + + +print("✅ report.zip created successfully!") diff --git a/tasks/report_bundle/grids/grid1.png b/tasks/report_bundle/grids/grid1.png new file mode 100644 index 00000000..18d16099 Binary files /dev/null and b/tasks/report_bundle/grids/grid1.png differ diff --git a/tasks/report_bundle/grids/grid2.png b/tasks/report_bundle/grids/grid2.png new file mode 100644 index 00000000..2b8b6583 Binary files /dev/null and b/tasks/report_bundle/grids/grid2.png differ diff --git a/tasks/report_bundle/results.csv b/tasks/report_bundle/results.csv new file mode 100644 index 00000000..8931aa71 --- /dev/null +++ b/tasks/report_bundle/results.csv @@ -0,0 +1,3 @@ +id,image_path,score +1,grids/grid1.png,0.95 +2,grids/grid2.png,0.88 diff --git a/tasks/report_bundle/test_schema.py b/tasks/report_bundle/test_schema.py new file mode 100644 index 00000000..f5838bdb --- /dev/null +++ b/tasks/report_bundle/test_schema.py @@ -0,0 +1,14 @@ +import csv + +def test_csv_schema(filename): + required_columns = {'id', 'image_path', 'score'} + with open(filename, newline='') as csvfile: + reader = csv.DictReader(csvfile) + headers = set(reader.fieldnames) + missing = required_columns - headers + if missing: + raise ValueError(f"CSV is missing required columns: {missing}") + print("✅ CSV schema test passed!") + +if __name__ == "__main__": + test_csv_schema('results.csv')