소스 검색

feat: add JSONProducer

Outputs a representation of the Features extrated by the pipeline

Intent is to write a FE that takes the output so that a pipeline can be
're-run'

Output JSON could also be used with external tools
main
Rob Hallam 2 달 전
부모
커밋
4ecc95174e
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. +13
    -0
      pipeline/video_producers.py

+ 13
- 0
pipeline/video_producers.py 파일 보기

@@ -1,6 +1,7 @@
"""Classes for producing videos"""

from abc import ABC
import json
import logging
import os
import subprocess
@@ -139,3 +140,15 @@ class VisualisationProducer(Producer):
# save the plot
plt.savefig("/tmp/visualisation.png")
plt.close()

class JSONProducer(Producer):
"""Produce JSON output"""
def __init__(self, features):
if not features:
raise ValueError("No features provided")
self.features = features

def produce(self):
# FIXME: config option for output path
with open("/tmp/features.json", "w") as jsonfile:
jsonfile.write(json.dumps(self.features, cls=PipelineJSONEncoder, indent=4))

불러오는 중...
취소
저장