Spaces:
Runtime error
Runtime error
File size: 1,296 Bytes
8892aa7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
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

# 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

### Predicted Image

""".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))
|