Skip to content

Commit

Permalink
feat(cli): support offset
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Sep 3, 2019
1 parent 745f4fc commit c902361
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions stagesepx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def one_step(self,
threshold: float = 0.95,
frame_count: int = 5,
compress_rate: float = 0.2,
offset: int = None,
limit: int = None):
"""
one step => cut, classifier, draw
Expand All @@ -35,6 +36,10 @@ def one_step(self,
:param threshold: float, 0-1, default to 0.95. decided whether a range is stable. larger => more unstable ranges
:param frame_count: default to 5, and finally you will get 5 frames for each range
:param compress_rate: before_pic * compress_rate = after_pic. default to 0.2
:param offset:
it will change the way to decided whether two ranges can be merged
before: first_range.end == second_range.start
after: first_range.end + offset >= secord_range.start
:param limit: ignore some ranges which are too short, 5 means ignore stable ranges which length < 5
:return:
"""
Expand All @@ -45,6 +50,7 @@ def one_step(self,
stable, unstable = res.get_range(
threshold=threshold,
limit=limit,
offset=offset,
)

data_home = res.pick_and_save(
Expand Down Expand Up @@ -75,10 +81,16 @@ def cut(self,
threshold: float = 0.95,
frame_count: int = 5,
compress_rate: float = 0.2,
offset: int = None,
limit: int = None):

cutter = VideoCutter()
res = cutter.cut(video_path, compress_rate=compress_rate)
stable, unstable = res.get_range(threshold=threshold, limit=limit)
stable, unstable = res.get_range(
threshold=threshold,
limit=limit,
offset=offset
)

data_home = res.pick_and_save(
stable,
Expand All @@ -92,6 +104,7 @@ def classify(self,
data_home: str,
output_path: str = None,
compress_rate: float = 0.2,
offset: int = None,
limit: int = None):
# TODO model?

Expand All @@ -101,7 +114,10 @@ def classify(self,
stable = None
if os.path.isfile(cut_result_json):
res = VideoCutResult.load(cut_result_json)
stable, _ = res.get_range(limit=limit)
stable, _ = res.get_range(
offset=offset,
limit=limit
)

cl = SVMClassifier(compress_rate=compress_rate)
cl.load(data_home)
Expand Down

0 comments on commit c902361

Please sign in to comment.