From ff30046bced8ac56b910f76fcc20c78cba271750 Mon Sep 17 00:00:00 2001 From: Keigh Rim Date: Fri, 15 Dec 2023 10:31:50 -0500 Subject: [PATCH] made `classify` as a submodule under `modeling` package. --- app.py | 14 ++++++++------ classify.py => modeling/classify.py | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) rename classify.py => modeling/classify.py (99%) diff --git a/app.py b/app.py index d782beb..bfc3653 100644 --- a/app.py +++ b/app.py @@ -12,10 +12,9 @@ import yaml from clams import ClamsApp, Restifier -from mmif import Mmif, View, Annotation, Document, AnnotationTypes, DocumentTypes - -import classify +from mmif import Mmif, View, AnnotationTypes, DocumentTypes +from modeling import classify logging.basicConfig(filename='swt.log', level=logging.DEBUG) @@ -41,13 +40,16 @@ def _annotate(self, mmif: Union[str, dict, Mmif], **parameters) -> Mmif: return mmif vd = vds[0] + # aad the timeframes to a new view and return the updated Mmif object + new_view: View = mmif.new_view() + self.sign_view(new_view, parameters) + parameters = self.get_configuration(parameters) + # calculate the frame predictions and extract the timeframes + # use `parameters` as needed as runtime configuration predictions = self.classifier.process_video(vd.location) timeframes = self.classifier.extract_timeframes(predictions) - # aad the timeframes to a new view and return the updated Mmif object - new_view: View = mmif.new_view() - self.sign_view(new_view, parameters) new_view.new_contain(AnnotationTypes.TimeFrame, document=vd.id) for tf in timeframes: start, end, score, label = tf diff --git a/classify.py b/modeling/classify.py similarity index 99% rename from classify.py rename to modeling/classify.py index c10898d..f7d079a 100644 --- a/classify.py +++ b/modeling/classify.py @@ -62,7 +62,6 @@ def process_video(self, mp4_file: str): an instance of numpy.ndarray.""" print(f'Processing {mp4_file}...') logging.info(f'processing {mp4_file}...') - basename = os.path.splitext(os.path.basename(mp4_file))[0] predictions = [] vidcap = cv2.VideoCapture(mp4_file) fps = round(vidcap.get(cv2.CAP_PROP_FPS), 2)