Skip to content

Commit c4e1b46

Browse files
committed
remove default values for indexing functions
1 parent 9c961f2 commit c4e1b46

2 files changed

Lines changed: 38 additions & 42 deletions

File tree

videodb/rtstream.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,13 @@ def index_audio(
499499
:return: Scene index, :class:`RTStreamSceneIndex <RTStreamSceneIndex>` object
500500
:rtype: :class:`videodb.rtstream.RTStreamSceneIndex`
501501
"""
502-
# Default batch_config
503-
if batch_config is None:
504-
batch_config = {"type": "word", "value": 10}
505-
506-
segmenter = batch_config.get("type", Segmenter.word)
507-
segmentation_value = batch_config.get("value", 10)
508-
509-
extraction_config = {
510-
"segmenter": segmenter,
511-
"segmentation_value": segmentation_value,
512-
}
502+
if batch_config is not None:
503+
extraction_config = {
504+
"segmenter": batch_config.get("type"),
505+
"segmentation_value": batch_config.get("value"),
506+
}
507+
else:
508+
extraction_config = None
513509

514510
data = {
515511
"extraction_type": SceneExtractionType.transcript,
@@ -562,14 +558,13 @@ def index_visuals(
562558
:return: Scene index, :class:`RTStreamSceneIndex <RTStreamSceneIndex>` object
563559
:rtype: :class:`videodb.rtstream.RTStreamSceneIndex`
564560
"""
565-
# Default batch_config
566-
if batch_config is None:
567-
batch_config = {"type": "time", "value": 2, "frame_count": 5}
568-
569-
extraction_config = {
570-
"time": batch_config.get("value", 2),
571-
"frame_count": batch_config.get("frame_count", 5),
572-
}
561+
if batch_config is not None:
562+
extraction_config = {
563+
"time": batch_config.get("value"),
564+
"frame_count": batch_config.get("frame_count"),
565+
}
566+
else:
567+
extraction_config = None
573568

574569
data = {
575570
"extraction_type": SceneExtractionType.time_based,

videodb/video.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -551,23 +551,24 @@ def index_visuals(
551551
:return: The scene index id
552552
:rtype: str
553553
"""
554-
if batch_config is None:
555-
batch_config = {"type": "time", "value": 10, "frame_count": 1}
556-
557-
extraction_type = batch_config.get("type", "time")
558-
if extraction_type == "shot":
559-
extraction_type = SceneExtractionType.shot_based
560-
extraction_config = {
561-
"threshold": batch_config.get("value", 20),
562-
"frame_count": batch_config.get("frame_count", 1),
563-
}
554+
if batch_config is not None:
555+
extraction_type = batch_config.get("type")
556+
if extraction_type == "shot":
557+
extraction_type = SceneExtractionType.shot_based
558+
extraction_config = {
559+
"threshold": batch_config.get("value"),
560+
"frame_count": batch_config.get("frame_count"),
561+
}
562+
else:
563+
extraction_type = SceneExtractionType.time_based
564+
extraction_config = {
565+
"time": batch_config.get("value"),
566+
"frame_count": batch_config.get("frame_count"),
567+
"select_frames": batch_config.get("select_frames"),
568+
}
564569
else:
565-
extraction_type = SceneExtractionType.time_based
566-
extraction_config = {
567-
"time": batch_config.get("value", 10),
568-
"frame_count": batch_config.get("frame_count", 1),
569-
"select_frames": batch_config.get("select_frames", ["first"]),
570-
}
570+
extraction_type = None
571+
extraction_config = None
571572

572573
scenes_data = self._connection.post(
573574
path=f"{ApiPath.video}/{self.id}/{ApiPath.index}/{ApiPath.scene}",
@@ -614,13 +615,13 @@ def index_audio(
614615
:return: The scene index id
615616
:rtype: str
616617
"""
617-
if batch_config is None:
618-
batch_config = {"type": Segmenter.word, "value": 10}
619-
620-
extraction_config = {
621-
"segmenter": batch_config.get("type", Segmenter.word),
622-
"segmentation_value": batch_config.get("value", 10),
623-
}
618+
if batch_config is not None:
619+
extraction_config = {
620+
"segmenter": batch_config.get("type"),
621+
"segmentation_value": batch_config.get("value"),
622+
}
623+
else:
624+
extraction_config = None
624625

625626
scenes_data = self._connection.post(
626627
path=f"{ApiPath.video}/{self.id}/{ApiPath.index}/{ApiPath.scene}",

0 commit comments

Comments
 (0)