Skip to content

Commit

Permalink
made classify as a submodule under modeling package.
Browse files Browse the repository at this point in the history
  • Loading branch information
keighrim committed Dec 15, 2023
1 parent 1df5017 commit ff30046
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 8 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion classify.py → modeling/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ff30046

Please sign in to comment.