import os def render(kernel, epochs, train_datasets, valid_datasets, val_images, accuracy, precision, recall): return f""" # Model Info * Kernel: {kernel} * Epochs: {epochs} * TrainSet: {train_datasets} * ValidSet: {valid_datasets} # Metrics * Accuracy: {accuracy} * Precision: {precision} * Recall: {recall} # Confusion Matrix ![confusion_matrix](./confusion_matrix.png) # Valid Image Example {render_list(val_images)} """.strip() def render_list(lst): return "".join(render_list_iter(lst)) def render_list_iter(lst): for item in lst: yield f"""{render_item(item)}\n""" def render_item(item: tuple[str, str]): original, pred = item return f""" ### Original Image ![original_image]({original}) ### Predicted Image ![predicted_image]({pred}) """.strip() def main(val_images: list[tuple[str, str]]): return render(kernel='yolov5s', epochs=100, train_datasets='coco', valid_datasets='coco', val_images=val_images, accuracy=0.9, precision=0.8, recall=0.7) if __name__ == '__main__': out = 'datasets/coco8/images/report/report.md' imgs = list(map(lambda x: (f"../val/{x}", f"../val/{x}"), os.listdir('datasets/coco8/images/val'))) with open(out, 'w') as f: f.write(main(val_images=imgs))