code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def __init__(self,
min_len: int = 10,
max_len: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param min_len: The min text length in the filtering. samples
will be filtered if their text length is b... |
Initialization method.
:param min_len: The min text length in the filtering. samples
will be filtered if their text length is below this
parameter.
:param max_len: The max text length in the filtering. samples
will be filtered if their text length exceeds th... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_length_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_length_filter.py | Apache-2.0 |
def __init__(self,
hf_clip='openai/clip-vit-base-patch32',
trust_remote_code=False,
min_score: ClosedUnitInterval = 0.1,
max_score: ClosedUnitInterval = 1.0,
text_key_second=None,
any_or_all: str = 'any',
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between image and text.
:param min_score: The min similarity to keep samples.
:param max_score: The max similarity to keep samples.
:param text_key_second: used to store the ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_pair_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_pair_similarity_filter.py | Apache-2.0 |
def __init__(self,
hf_tokenizer: str = 'EleutherAI/pythia-6.9b-deduped',
min_num: int = 10,
max_num: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param hf_tokenizer: the tokenizer name of Hu... |
Initialization method.
:param hf_tokenizer: the tokenizer name of Hugging Face tokenizers.
:param min_num: The min filter token number in this op, samples
will be filtered if their token number is below this
parameter.
:param max_num: The max filter token number... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/token_num_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/token_num_filter.py | Apache-2.0 |
def __init__(self,
hf_scorer_model: str = '',
trust_remote_code: bool = False,
min_score: float = 0.4,
max_score: float = 1.0,
frame_sampling_method: str = 'uniform',
frame_num: PositiveInt = 3,
any_or... |
Initialization method.
:param hf_scorer_model: Huggingface model name for the aesthetics
predictor. By default, we will use
'shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE',
refer to pypi.org/project/simple-aesthetics-predictor
:param min_scor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_aesthetics_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_aesthetics_filter.py | Apache-2.0 |
def __init__(self,
min_ratio: str = '9/21',
max_ratio: str = '21/9',
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_ratio: The minimum aspect ratio to keep samples,
... |
Initialization method.
:param min_ratio: The minimum aspect ratio to keep samples,
supported format is a string, such as "9:21" or "9/21".
:param max_ratio: The maximum aspect ratio to keep samples,
supported format is a string, such as "21:9" or "21/9".
:param ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_aspect_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_aspect_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_duration: float = 0,
max_duration: float = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_duration: The min video duration to keep samples i... |
Initialization method.
:param min_duration: The min video duration to keep samples in seconds.
It's 0 by default.
:param max_duration: The max video duration to keep samples in seconds.
It's sys.maxsize by default.
:param any_or_all: keep this sample with 'any' ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_duration_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_duration_filter.py | Apache-2.0 |
def __init__(self,
hf_clip='openai/clip-vit-base-patch32',
trust_remote_code=False,
min_score: float = 0.1,
max_score: float = 1.0,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between frame image and text. It's kind of
language-related. For example, for Chinese datasets, ChineseCLIP
might be a better choice.
:param min_score: the min si... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_frames_text_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_frames_text_similarity_filter.py | Apache-2.0 |
def __init__(self,
min_score: float = 0.25,
max_score: float = sys.float_info.max,
sampling_fps: PositiveFloat = 2,
size: Union[PositiveInt, Tuple[PositiveInt],
Tuple[PositiveInt, PositiveInt], None] = None,
... |
Initialization method.
:param min_score: The minimum motion score to keep samples.
:param max_score: The maximum motion score to keep samples.
:param sampling_fps: The sampling rate in frames_per_second for
optical flow calculations.
:param size: Resize frames befor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_motion_score_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_motion_score_filter.py | Apache-2.0 |
def __init__(self,
hf_nsfw_model: str = 'Falconsai/nsfw_image_detection',
trust_remote_code: bool = False,
max_score: float = 0.5,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
reduce_mode: ... |
Initialization method.
:param hf_nsfw_model: nsfw detection model name on huggingface.
:param max_score: the nsfw score threshold for samples.
range from 0 to 1. Samples with nsfw score less than this threshold
will be kept.
:param frame_sampling_method: samplin... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_nsfw_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_nsfw_filter.py | Apache-2.0 |
def triangle_area(p1, p2, p3):
"""
Compute the triangle area according to its coordinates.
"""
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
tri_area = 0.5 * np.abs(x1 * y2 + x2 * y3 + x3 * y1 - x2 * y1 - x3 * y2 -
x1 * y3)
return tri_area |
Compute the triangle area according to its coordinates.
| triangle_area | python | modelscope/data-juicer | data_juicer/ops/filter/video_ocr_area_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_ocr_area_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_area_ratio: float = 0,
max_area_ratio: float = 1.0,
frame_sample_num: PositiveInt = 3,
languages_to_detect: Union[str, List[str]] = ['ch_sim', 'en'],
any_or_all: str = 'any',
*args,
... |
Initialization method.
:param min_area_ratio: The min ocr area ratio to keep samples. It's 0
by default.
:param max_area_ratio: The max ocr area ratio to keep samples. It's 1.0
by default.
:param frame_sample_num: The number of sampled frames to calculate the
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_ocr_area_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_ocr_area_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_width: int = 1,
max_width: int = sys.maxsize,
min_height: int = 1,
max_height: int = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization me... |
Initialization method.
:param min_width: The min horizontal resolution.
:param max_width: The max horizontal resolution.
:param min_height: The min vertical resolution.
:param max_height: The max vertical resolution.
:param any_or_all: keep this sample with 'any' or 'al... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_resolution_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_resolution_filter.py | Apache-2.0 |
def __init__(self,
tags: List[str] = ['people'],
contain: str = 'any',
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
tag_field_name: str = MetaKeys.video_frame_tags,
any_or_all: str = 'any',... |
Initialization method.
:param tags: a tag list to shift the videos, total tags can be found
in https://github.com/xinyu1205/recognize-anything/blob/main/ram/data/ram_tag_list.txt # noqa: E501
:param contain: require the videos containing 'any' or 'all' tags.
When tags e... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_tagging_from_frames_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_tagging_from_frames_filter.py | Apache-2.0 |
def __init__(self,
hf_watermark_model: str = 'amrul-hzz/watermark_detector',
trust_remote_code: bool = False,
prob_threshold: float = 0.8,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
reduc... |
Initialization method.
:param hf_watermark_model: watermark detection model name on
huggingface.
:param prob_threshold: the predicted watermark probability threshold
for samples. range from 0 to 1. Samples with watermark probability
less than this threshold ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_watermark_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_watermark_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
min_num: int = 10,
max_num: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param lang: sample in which languag... |
Initialization method.
:param lang: sample in which language.
:param tokenization: whether to use model to tokenize documents
:param min_num: The min filter word number in this op, samples
will be filtered if their word number is below this
parameter.
:p... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/words_num_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/words_num_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
rep_len: PositiveInt = 10,
min_ratio: float = 0.0,
max_ratio: float = 0.5,
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param lang: sample in which language.
:param tokenization: whether to use model to tokenize documents
:param rep_len: Repetition length for word-level n-gram.
:param min_ratio: The min filter ratio in this op, samples will
be filtered if thei... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/word_repetition_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/word_repetition_filter.py | Apache-2.0 |
def __init__(self,
group_by_keys: Optional[List[str]] = None,
*args,
**kwargs):
"""
Initialization method.
:param group_by_keys: group samples according values in the keys.
Support for nested keys such as "__dj__stats__.text_len".
... |
Initialization method.
:param group_by_keys: group samples according values in the keys.
Support for nested keys such as "__dj__stats__.text_len".
It is [self.text_key] in default.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/grouper/key_value_grouper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/grouper/key_value_grouper.py | Apache-2.0 |
def __init__(self, batch_meta_export_path=None, *args, **kwargs):
"""
Initialization method.
:param batch_meta_export_path: the path to export the batch meta.
Just drop the batch meta if it is None.
:param args: extra args
:param kwargs: extra args
"""
... |
Initialization method.
:param batch_meta_export_path: the path to export the batch meta.
Just drop the batch meta if it is None.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/grouper/naive_reverse_grouper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/grouper/naive_reverse_grouper.py | Apache-2.0 |
def __init__(self,
min_amplitude: float = 0.001,
max_amplitude: float = 0.015,
p: float = 0.5,
*args,
**kwargs):
"""
Initialization method.
min_amplitude: float unit: linear amplitude.
Default: 0.0... |
Initialization method.
min_amplitude: float unit: linear amplitude.
Default: 0.001. Minimum noise amplification factor.
max_amplitude: float unit: linear amplitude.
Default: 0.015. Maximum noise amplification factor.
p: float range: [0.0, 1.0]. Default: 0.5.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/audio_add_gaussian_noise_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/audio_add_gaussian_noise_mapper.py | Apache-2.0 |
def __init__(
self,
filter_name: Optional[str] = None,
filter_kwargs: Optional[Dict] = None,
global_args: Optional[List[str]] = None,
capture_stderr: bool = True,
overwrite_output: bool = True,
*args,
**kwargs,
):
"""
Initialization met... |
Initialization method.
:param filter_name: ffmpeg audio filter name.
:param filter_kwargs: keyword-arguments passed to ffmpeg filter.
:param global_args: list-arguments passed to ffmpeg command-line.
:param capture_stderr: whether to capture stderr.
:param overwrite_out... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/audio_ffmpeg_wrapped_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/audio_ffmpeg_wrapped_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
system_prompt: Optional[str] = None,
input_template: Optional[str] = None,
refe... |
Initialization method.
:param api_model: API model name.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content from the API response.
Defaults to 'choices.0.message.content'.
:param system_prompt: System prompt for the calibrat... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/calibrate_qa_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/calibrate_qa_mapper.py | Apache-2.0 |
def __init__(self, *args, **kwargs):
"""
Initialization method.
:param args: extra args
:param kwargs: extra args
"""
super().__init__(*args, **kwargs)
self.pat = re.compile('/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/')
self.cpat = re.compile('copyright', re.IGNOR... |
Initialization method.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/clean_copyright_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/clean_copyright_mapper.py | Apache-2.0 |
def __init__(self,
pattern: Optional[str] = None,
repl: str = '',
*args,
**kwargs):
"""
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, defau... |
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, default is empty string.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/clean_email_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/clean_email_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
intent_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_intent_labels,
analysis_key: str = MetaKeys.dialog_inten... |
Initialization method.
:param api_model: API model name.
:param intent_candidates: The output intent candidates. Use the
intent labels of the open domain if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labe... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_intent_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_intent_detection_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
sentiment_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_sentiment_labels,
analysis_key: str = MetaKeys.dialog... |
Initialization method.
:param api_model: API model name.
:param sentiment_candidates: The output sentiment candidates. Use
open-domain sentiment labels if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labels... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_sentiment_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_sentiment_detection_mapper.py | Apache-2.0 |
def __init__(
self,
api_model: str = 'gpt-4o',
max_round: NonNegativeInt = 10,
*,
intensities_key: str = MetaKeys.dialog_sentiment_intensity,
analysis_key: str = MetaKeys.dialog_sentiment_intensity_analysis,
api_endpoint: Optional[str] ... |
Initialization method.
:param api_model: API model name.
:param max_round: The max num of round in the dialog to build the
prompt.
:param intensities_key: The key name in the meta field to store
the output sentiment intensities. It is
'dialog_sentime... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_sentiment_intensity_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_sentiment_intensity_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
topic_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_topic_labels,
analysis_key: str = MetaKeys.dialog_topic_l... |
Initialization method.
:param api_model: API model name.
:param topic_candidates: The output topic candidates. Use
open-domain topic labels if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labels_key: The ke... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_topic_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_topic_detection_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
query_entities: List[str] = [],
query_attributes: List[str] = [],
*,
entity_key: str = MetaKeys.main_entities,
attribute_key: str = MetaKeys.attributes,
at... |
Initialization method.
:param api_model: API model name.
:param query_entities: Entity list to be queried.
:param query_attributes: Attribute list to be queried.
:param entity_key: The key name in the meta field to store the
given main entity for attribute extraction... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_entity_attribute_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_entity_attribute_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
event_desc_key: str = MetaKeys.event_description,
relevant_char_key: str = MetaKeys.relevant_characters,
api_endpoint: Optional[str] = None,
response_path: Optional[str]... |
Initialization method.
:param api_model: API model name.
:param event_desc_key: The key name to store the event descriptions
in the meta field. It's "event_description" in default.
:param relevant_char_key: The field name to store the relevant
characters to the e... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_event_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_event_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
nickname_key: str = MetaKeys.nickname,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
system_prompt: Optional[str] = None,
inp... |
Initialization method.
:param api_model: API model name.
:param nickname_key: The key name to store the nickname
relationship in the meta field. It's "nickname" in default.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content f... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_nickname_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_nickname_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
summary_key: str = MetaKeys.event_description,
support_text_key: str = MetaKeys.support_text,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
... |
Initialization method.
:param api_model: API model name.
:param summary_key: The key name to store the input summary in the
meta field. It's "event_description" in default.
:param support_text_key: The key name to store the output
support text for the summary in ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_support_text_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_support_text_mapper.py | Apache-2.0 |
def __init__(self,
tables_field_name: str = MetaKeys.html_tables,
retain_html_tags: bool = False,
include_header: bool = True,
*args,
**kwargs):
"""
Initialization method.
:param tables_field_name: Field name to... |
Initialization method.
:param tables_field_name: Field name to store the extracted tables.
:param retain_html_tags: If True, retains HTML tags in the tables;
otherwise, removes them.
:param include_header: If True, includes the table header;
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_tables_from_html_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_tables_from_html_mapper.py | Apache-2.0 |
def __init__(self, normalization: str = None, *args, **kwargs):
"""
Initialization method.
:param normalization: the specified form of Unicode
normalization mode, which can be one of
['NFC', 'NFKC', 'NFD', and 'NFKD'], default 'NFC'.
:param args: extra args
... |
Initialization method.
:param normalization: the specified form of Unicode
normalization mode, which can be one of
['NFC', 'NFKC', 'NFD', and 'NFKD'], default 'NFC'.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/fix_unicode_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/fix_unicode_mapper.py | Apache-2.0 |
def __init__(self,
hf_model: str = 'Qwen/Qwen2.5-7B-Instruct',
*,
seed_file: str = '',
example_num: PositiveInt = 3,
similarity_threshold: float = 0.7,
system_prompt: Optional[str] = None,
input_templa... |
Initialization method.
:param hf_model: Huggingface model ID.
:param seed_file: Path to the seed file in chatml format.
:param example_num: The number of selected examples.
Randomly select N examples from "seed_file" and
put them into prompt as QA examples.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | Apache-2.0 |
def _load_seed_qa_samples(self):
"""Load QA pairs from chatml format file."""
qa_samples = []
with open(self.seed_file, encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
qa_pairs = self._parse_chatml_str(l... | Load QA pairs from chatml format file. | _load_seed_qa_samples | python | modelscope/data-juicer | data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | Apache-2.0 |
def __init__(self,
p: float = 0.2,
blur_type: str = 'gaussian',
radius: float = 2,
*args,
**kwargs):
"""
Initialization method.
:param p: Probability of the image being blurred.
:param blur_type: Type o... |
Initialization method.
:param p: Probability of the image being blurred.
:param blur_type: Type of blur kernel, including
['mean', 'box', 'gaussian'].
:param radius: Radius of blur kernel.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_blur_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_blur_mapper.py | Apache-2.0 |
def __init__(self,
mode: str = 'description',
api_key: str = '',
max_token: int = 500,
temperature: Annotated[float, Field(ge=0, le=1)] = 1.0,
system_prompt: str = '',
user_prompt: str = '',
user_promp... |
Initialization method.
:param mode: mode of text generated from images, can be one of
['reasoning', 'description', 'conversation', 'custom']
:param api_key: the API key to authenticate the request.
:param max_token: the maximum number of tokens to generate.
Defa... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_from_gpt4v_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_from_gpt4v_mapper.py | Apache-2.0 |
def __init__(self,
hf_img2seq: str = 'Salesforce/blip2-opt-2.7b',
trust_remote_code: bool = False,
caption_num: PositiveInt = 1,
keep_candidate_mode: str = 'random_any',
keep_original_sample: bool = True,
prompt: Optio... |
Initialization method.
:param hf_img2seq: model name on huggingface to generate caption
:param caption_num: how many candidate captions to generate
for each image
:param keep_candidate_mode: retain strategy for the generated
$caption_num$ candidates.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_mapper.py | Apache-2.0 |
def _process_single_sample(self, ori_sample, rank=None):
"""
:param ori_sample: a single data sample before applying generation
:return: batched results after generation
"""
# there is no image in this sample
if self.image_key not in ori_sample or \
not o... |
:param ori_sample: a single data sample before applying generation
:return: batched results after generation
| _process_single_sample | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_mapper.py | Apache-2.0 |
def process_batched(self, samples, rank=None):
"""
Note:
This is a batched_OP, whose input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote caption_num as $M$.
the number of total samples after gener... |
Note:
This is a batched_OP, whose input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote caption_num as $M$.
the number of total samples after generation is $2Nb$
for 'random_any' and 'similar_o... | process_batched | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_mapper.py | Apache-2.0 |
def _process_single_sample(self, ori_sample, rank=None, context=False):
"""
:param ori_sample: a single data sample before applying generation
:return: batched results after generation
"""
# there is no image in this sample
if self.image_key not in ori_sample or \
... |
:param ori_sample: a single data sample before applying generation
:return: batched results after generation
| _process_single_sample | python | modelscope/data-juicer | data_juicer/ops/mapper/image_diffusion_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_diffusion_mapper.py | Apache-2.0 |
def process_batched(self, samples, rank=None, context=False):
"""
Note:
This is a batched_OP, whose the input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote aug_num as $M$.
the ... |
Note:
This is a batched_OP, whose the input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote aug_num as $M$.
the number of total samples after generation is $(1+M)Nb$.
:par... | process_batched | python | modelscope/data-juicer | data_juicer/ops/mapper/image_diffusion_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_diffusion_mapper.py | Apache-2.0 |
def __init__(self,
cv_classifier: str = '',
blur_type: str = 'gaussian',
radius: NonNegativeFloat = 2,
*args,
**kwargs):
"""
Initialization method.
:param cv_classifier: OpenCV classifier path for face detectio... |
Initialization method.
:param cv_classifier: OpenCV classifier path for face detection.
By default, we will use 'haarcascade_frontalface_alt.xml'.
:param blur_type: Type of blur kernel, including
['mean', 'box', 'gaussian'].
:param radius: Radius of blur kernel.... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_face_blur_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_face_blur_mapper.py | Apache-2.0 |
def __init__(self,
alpha_matting: bool = False,
alpha_matting_foreground_threshold: int = 240,
alpha_matting_background_threshold: int = 10,
alpha_matting_erode_size: int = 10,
bgcolor: Optional[Tuple[int, int, int, int]] = None,
... |
Initialization method.
alpha_matting (bool, optional):
Flag indicating whether to use alpha matting. Defaults to False.
alpha_matting_foreground_threshold (int, optional):
Foreground threshold for alpha matting. Defaults to 240.
alpha_matting_background_threshol... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_remove_background_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_remove_background_mapper.py | Apache-2.0 |
def __init__(self,
imgsz=1024,
conf=0.05,
iou=0.5,
model_path='FastSAM-x.pt',
*args,
**kwargs):
"""
Initialization method.
:param imgsz: resolution for image resizing
:param conf: confi... |
Initialization method.
:param imgsz: resolution for image resizing
:param conf: confidence score threshold
:param iou: IoU (Intersection over Union) score threshold
:param model_path: the path to the FastSAM model. Model name should be
one of ['FastSAM-x.pt', 'FastS... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_segment_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_segment_mapper.py | Apache-2.0 |
def __init__(self,
tag_field_name: str = MetaKeys.image_tags,
*args,
**kwargs):
"""
Initialization method.
:param tag_field_name: the field name to store the tags. It's
"image_tags" in default.
:param args: extra args
... |
Initialization method.
:param tag_field_name: the field name to store the tags. It's
"image_tags" in default.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_tagging_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_tagging_mapper.py | Apache-2.0 |
def __init__(self,
hf_model: str = 'llava-hf/llava-v1.6-vicuna-7b-hf',
max_new_tokens=256,
temperature=0.2,
top_p=None,
num_beams=1,
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param hf_model: hugginface model id.
:param max_new_tokens: the maximum number of new tokens
generated by the model.
:param temperature: used to control the randomness of generated text. The higher the temperature, the more ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/mllm_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/mllm_mapper.py | Apache-2.0 |
def __init__(self,
sequential: bool = False,
aug_num: PositiveInt = 1,
keep_original_sample: bool = True,
delete_random_word: bool = False,
swap_random_word: bool = False,
spelling_error_word: bool = False,
... |
Initialization method. All augmentation methods use default parameters
in default. We recommend you to only use 1-3 augmentation methods at a
time. Otherwise, the semantics of samples might be changed
significantly.
:param sequential: whether combine all augmentation methods to... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/nlpaug_en_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/nlpaug_en_mapper.py | Apache-2.0 |
def __init__(self,
hf_model: str = 'Qwen/Qwen2.5-7B-Instruct',
*,
system_prompt: Optional[str] = None,
input_template: Optional[str] = None,
qa_pair_template: Optional[str] = None,
output_pattern: Optional[str] = None,... |
Initialization method.
:param hf_model: Hugging Face model ID.
:param system_prompt: System prompt for guiding the optimization task.
:param input_template: Template for building the input for the model.
Please make sure the template contains one placeholder '{}', which
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/optimize_qa_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/optimize_qa_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
system_prompt: Optional[str] = None,
input_template: Optional[str] = None,
outp... |
Initialization method.
:param api_model: API model name.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content from the API response.
Defaults to 'choices.0.message.content'.
:param system_prompt: System prompt for guiding the ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/pair_preference_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/pair_preference_mapper.py | Apache-2.0 |
def __init__(self,
file_path: str = '',
function_name: str = 'process_single',
batched: bool = False,
**kwargs):
"""
Initialization method.
:param file_path: The path to the Python file containing the function
to be... |
Initialization method.
:param file_path: The path to the Python file containing the function
to be executed.
:param function_name: The name of the function defined in the file
to be executed.
:param batched: A boolean indicating whether to process input data in
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/python_file_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/python_file_mapper.py | Apache-2.0 |
def process_single(self, sample):
"""Invoke the loaded function with the provided sample."""
result = self.func(sample)
if not isinstance(result, dict):
raise ValueError(
f'Function must return a dictionary, got {type(result).__name__} instead.' # noqa: E501
... | Invoke the loaded function with the provided sample. | process_single | python | modelscope/data-juicer | data_juicer/ops/mapper/python_file_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/python_file_mapper.py | Apache-2.0 |
def process_batched(self, samples):
"""Invoke the loaded function with the provided samples."""
result = self.func(samples)
if not isinstance(result, dict):
raise ValueError(
f'Function must return a dictionary, got {type(result).__name__} instead.' # noqa: E501
... | Invoke the loaded function with the provided samples. | process_batched | python | modelscope/data-juicer | data_juicer/ops/mapper/python_file_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/python_file_mapper.py | Apache-2.0 |
def __init__(self, lambda_str: str = '', batched: bool = False, **kwargs):
"""
Initialization method.
:param lambda_str: A string representation of the lambda function to be
executed on data samples. If empty, the identity function is used.
:param batched: A boolean indicati... |
Initialization method.
:param lambda_str: A string representation of the lambda function to be
executed on data samples. If empty, the identity function is used.
:param batched: A boolean indicating whether to process input data in
batches.
:param kwargs: Additi... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/python_lambda_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/python_lambda_mapper.py | Apache-2.0 |
def __init__(
self,
hf_model:
str = 'bespin-global/klue-roberta-small-3i4k-intent-classification', # noqa: E501 E131
zh_to_en_hf_model: Optional[str] = 'Helsinki-NLP/opus-mt-zh-en',
model_params: Dict = {},
zh_to_en_model_params: Dict = {},
... |
Initialization method.
:param hf_model: Huggingface model ID to predict intent label.
:param zh_to_en_hf_model: Translation model from Chinese to English.
If not None, translate the query from Chinese to English.
:param model_params: model param for hf_model.
:param... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/query_intent_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/query_intent_detection_mapper.py | Apache-2.0 |
def __init__(
self,
hf_model:
str = 'mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis', # noqa: E501 E131
zh_to_en_hf_model: Optional[str] = 'Helsinki-NLP/opus-mt-zh-en',
model_params: Dict = {},
zh_to_en_model_params: Dict = {},
... |
Initialization method.
:param hf_model: Huggingface model ID to predict sentiment label.
:param zh_to_en_hf_model: Translation model from Chinese to English.
If not None, translate the query from Chinese to English.
:param model_params: model param for hf_model.
:pa... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/query_sentiment_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/query_sentiment_detection_mapper.py | Apache-2.0 |
def __init__(
self,
hf_model:
str = 'dstefa/roberta-base_topic_classification_nyt_news', # noqa: E501 E131
zh_to_en_hf_model: Optional[str] = 'Helsinki-NLP/opus-mt-zh-en',
model_params: Dict = {},
zh_to_en_model_params: Dict = {},
*,
... |
Initialization method.
:param hf_model: Huggingface model ID to predict topic label.
:param zh_to_en_hf_model: Translation model from Chinese to English.
If not None, translate the query from Chinese to English.
:param model_params: model param for hf_model.
:param ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/query_topic_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/query_topic_detection_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
source_entity: str = None,
target_entity: str = None,
*,
output_key: str = MetaKeys.role_relation,
api_endpoint: Optional[str] = None,
response_path: Optio... |
Initialization method.
:param api_model: API model name.
:param source_entity: The source entity of the relation to be
identified.
:param target_entity: The target entity of the relation to be
identified.
:param output_key: The output key in the meta fiel... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/relation_identity_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/relation_identity_mapper.py | Apache-2.0 |
def __init__(self,
doc_type: Union[str, List[str]] = 'tex',
inline: bool = True,
multiline: bool = True,
*args,
**kwargs):
"""
Initialization method.
:param doc_type: Type of document to remove comments.
... |
Initialization method.
:param doc_type: Type of document to remove comments.
:param inline: Whether to remove inline comments.
:param multiline: Whether to remove multiline comments.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_comments_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_comments_mapper.py | Apache-2.0 |
def __init__(self, drop_no_head: bool = True, *args, **kwargs):
"""
Initialization method.
:param drop_no_head: whether to drop sample texts without
headers.
:param args: extra args
:param kwargs: extra args
"""
super().__init__(*args, **kwargs)
... |
Initialization method.
:param drop_no_head: whether to drop sample texts without
headers.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_header_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_header_mapper.py | Apache-2.0 |
def __init__(self,
min_len: int = 1,
max_len: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param min_len: The min mapper word length in this op, words
will be filtered if their length is below th... |
Initialization method.
:param min_len: The min mapper word length in this op, words
will be filtered if their length is below this parameter.
:param max_len: The max mapper word length in this op, words
will be filtered if their length exceeds this parameter.
:p... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_long_words_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_long_words_mapper.py | Apache-2.0 |
def __init__(self,
lowercase: bool = False,
ignore_special_character: bool = True,
min_repeat_sentence_length: int = 2,
*args,
**kwargs):
"""
Initialization method.
:param lowercase: Whether to convert sample t... |
Initialization method.
:param lowercase: Whether to convert sample text to lower case
:param ignore_special_character: Whether to ignore special
characters when judging repeated sentences. Special characters
are all characters except Chinese characters, letters and
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_repeat_sentences_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_repeat_sentences_mapper.py | Apache-2.0 |
def __init__(self,
min_col: Annotated[int, Field(ge=2, le=20)] = 2,
max_col: Annotated[int, Field(ge=2, le=20)] = 20,
*args,
**kwargs):
"""
Initialization method.
:param min_col: The min number of columns of table to remove.
... |
Initialization method.
:param min_col: The min number of columns of table to remove.
:param max_col: The max number of columns of table to remove.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_table_text_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_table_text_mapper.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
substrings: Optional[List[str]] = None,
*args,
**kwargs):
"""
Initialization method.
:param lang: sample in which language
:param tokeniz... |
Initialization method.
:param lang: sample in which language
:param tokenization: whether to use model to tokenize documents
:param substrings: The incorrect substrings in words.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/remove_words_with_incorrect_substrings_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/remove_words_with_incorrect_substrings_mapper.py | Apache-2.0 |
def __init__(self,
pattern: Union[str, List[str], None] = None,
repl: Union[str, List[str]] = '',
*args,
**kwargs):
"""
Initialization method.
:param pattern: regular expression pattern(s) to search for within text
:par... |
Initialization method.
:param pattern: regular expression pattern(s) to search for within text
:param repl: replacement string(s), default is empty string
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/replace_content_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/replace_content_mapper.py | Apache-2.0 |
def __init__(
self,
hf_diffusion: str = 'stabilityai/stable-diffusion-xl-base-1.0',
trust_remote_code=False,
torch_dtype: str = 'fp32',
num_inference_steps: float = 50,
guidance_scale: float = 7.5,
text_key=None,
text_key_se... |
Initialization method.
:param hf_diffusion: diffusion model name on huggingface to generate
the image.
:param torch_dtype: the floating point type used to load the diffusion
model.
:param num_inference_steps: The larger the value, the better the
image ge... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/sdxl_prompt2prompt_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/sdxl_prompt2prompt_mapper.py | Apache-2.0 |
def __init__(self,
hf_model: str = 'Qwen/Qwen2-7B-Instruct',
system_prompt: str = None,
task_sentence: str = None,
max_new_tokens=256,
temperature=0.2,
top_p=None,
num_beams=1,
text_ke... |
Initialization method.
:param hf_model: Huggingface model id.
:param system_prompt: System prompt.
:param task_sentence: The instruction for the current task.
:param max_new_tokens: the maximum number of new tokens
generated by the model.
:param temperature: ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/sentence_augmentation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/sentence_augmentation_mapper.py | Apache-2.0 |
def __init__(self, lang: str = 'en', *args, **kwargs):
"""
Initialization method.
:param lang: split sentence of text in which language.
:param args: extra args
:param kwargs: extra args
"""
super().__init__(*args, **kwargs)
self.lang = lang
# En... |
Initialization method.
:param lang: split sentence of text in which language.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/sentence_split_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/sentence_split_mapper.py | Apache-2.0 |
def __init__(self,
max_len: Union[PositiveInt, None] = None,
split_pattern: Union[str, None] = r'\n\n',
overlap_len: NonNegativeInt = 0,
tokenizer: Union[str, None] = None,
trust_remote_code: bool = False,
*args,
... |
Initialization method.
:param max_len: Split text into multi texts with this max len if not
None.
:param split_pattern: Make sure split in this pattern if it is not None
and force cut if the length exceeds max_len.
:param overlap_len: Overlap length of the split... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/text_chunk_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/text_chunk_mapper.py | Apache-2.0 |
def __init__(self, keep_original_sample: bool = True, *args, **kwargs):
"""
Initialization method.
:param keep_original_sample: whether to keep the original sample. If
it's set to False, there will be only captioned sample in the
final datasets and the original sample wi... |
Initialization method.
:param keep_original_sample: whether to keep the original sample. If
it's set to False, there will be only captioned sample in the
final datasets and the original sample will be removed. It's True
in default.
:param args: extra args
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_captioning_from_audio_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_captioning_from_audio_mapper.py | Apache-2.0 |
def __init__(
self,
hf_img2seq: str = 'Salesforce/blip2-opt-2.7b',
trust_remote_code: bool = False,
caption_num: PositiveInt = 1,
keep_candidate_mode: str = 'random_any',
keep_original_sample: bool = True,
prompt: Optional[str] = None,
prompt_key: Optional... |
Initialization method.
:param hf_img2seq: model name on huggingface to generate caption
:param caption_num: how many candidate captions to generate
for each video
:param keep_candidate_mode: retain strategy for the generated
$caption_num$ candidates.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_captioning_from_frames_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_captioning_from_frames_mapper.py | Apache-2.0 |
def process_batched(self, samples, rank=None, context=False):
"""
:param samples:
:return:
Note:
This is a batched_OP, whose the input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote caption_nu... |
:param samples:
:return:
Note:
This is a batched_OP, whose the input and output type are
both list. Suppose there are $N$ input sample list with batch
size as $b$, and denote caption_num as $M$.
the number of total samples after generation is $2N... | process_batched | python | modelscope/data-juicer | data_juicer/ops/mapper/video_captioning_from_frames_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_captioning_from_frames_mapper.py | Apache-2.0 |
def __init__(self,
hf_summarizer: str = None,
trust_remote_code: bool = False,
consider_video_caption_from_video: bool = True,
consider_video_caption_from_audio: bool = True,
consider_video_caption_from_frames: bool = True,
... |
Initialization method.
:param hf_summarizer: the summarizer model used to summarize texts
generated by other methods.
:param consider_video_caption_from_video: whether to consider the video
caption generated from video directly in the summarization process.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_captioning_from_summarizer_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_captioning_from_summarizer_mapper.py | Apache-2.0 |
def __init__(
self,
hf_video_blip: str = 'kpyu/video-blip-opt-2.7b-ego4d',
trust_remote_code: bool = False,
caption_num: PositiveInt = 1,
keep_candidate_mode: str = 'random_any',
keep_original_sample: bool = True,
prompt: Optional[str] = None,
prompt_key: ... |
Initialization method.
:param hf_video_blip: video-blip model name on huggingface
to generate caption
:param caption_num: how many candidate captions to generate
for each video
:param keep_candidate_mode: retain strategy for the generated
$caption_nu... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_captioning_from_video_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_captioning_from_video_mapper.py | Apache-2.0 |
def __init__(
self,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
duration: float = 0,
frame_dir: str = None,
frame_key=MetaKeys.video_frames,
*args,
**kwargs,
):
"""
Initialization method.
:param fra... |
Initialization method.
:param frame_sampling_method: sampling method of extracting frame
videos from the videos. Should be one of
["all_keyframes", "uniform"].
The former one extracts all key frames (the number
of which depends on the duration of the vide... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_extract_frames_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_extract_frames_mapper.py | Apache-2.0 |
def __init__(
self,
filter_name: Optional[str] = None,
filter_kwargs: Optional[Dict] = None,
global_args: Optional[List[str]] = None,
capture_stderr: bool = True,
overwrite_output: bool = True,
*args,
**kwargs,
):
"""
Initialization met... |
Initialization method.
:param filter_name: ffmpeg video filter name.
:param filter_kwargs: keyword-arguments passed to ffmpeg filter.
:param global_args: list-arguments passed to ffmpeg command-line.
:param capture_stderr: whether to capture stderr.
:param overwrite_out... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_ffmpeg_wrapped_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_ffmpeg_wrapped_mapper.py | Apache-2.0 |
def __init__(self,
roi_strings: List[str] = ['0,0,0.1,0.1'],
roi_type: str = 'ratio',
roi_key: Optional[str] = None,
frame_num: PositiveInt = 10,
min_frame_threshold: PositiveInt = 7,
detection_method: str = 'pixel_val... |
Initialization method.
:param roi_strings: a given list of regions the watermarks locate.
The format of each can be "x1, y1, x2, y2", "(x1, y1, x2, y2)",
or "[x1, y1, x2, y2]".
:param roi_type: the roi string type. When the type is 'pixel', (x1,
y1), (x2, y2... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_remove_watermark_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_remove_watermark_mapper.py | Apache-2.0 |
def __init__(
self,
min_ratio: str = '9/21',
max_ratio: str = '21/9',
strategy: str = 'increase',
*args,
**kwargs,
):
"""
Initialization method.
:param min_ratio: The minimum aspect ratio to enforce videos with
an aspect ratio belo... |
Initialization method.
:param min_ratio: The minimum aspect ratio to enforce videos with
an aspect ratio below `min_ratio` will be resized to match
this minimum ratio. The ratio should be provided as a string
in the format "9:21" or "9/21".
:param max_ratio:... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_resize_aspect_ratio_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_resize_aspect_ratio_mapper.py | Apache-2.0 |
def __init__(self,
min_width: int = 1,
max_width: int = sys.maxsize,
min_height: int = 1,
max_height: int = sys.maxsize,
force_original_aspect_ratio: str = 'disable',
force_divisible_by: PositiveInt = 2,
... |
Initialization method.
:param min_width: Videos with width less than 'min_width' will be
mapped to videos with equal or bigger width.
:param max_width: Videos with width more than 'max_width' will be
mapped to videos with equal of smaller width.
:param min_heigh... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_resize_resolution_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_resize_resolution_mapper.py | Apache-2.0 |
def __init__(self,
split_duration: float = 10,
min_last_split_duration: float = 0,
keep_original_sample: bool = True,
*args,
**kwargs):
"""
Initialization method.
:param split_duration: duration of each video s... |
Initialization method.
:param split_duration: duration of each video split in seconds.
:param min_last_split_duration: The minimum allowable duration in
seconds for the last video split. If the duration of the last
split is less than this value, it will be discarded.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_split_by_duration_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_split_by_duration_mapper.py | Apache-2.0 |
def __init__(self, keep_original_sample: bool = True, *args, **kwargs):
"""
Initialization method.
:param keep_original_sample: whether to keep the original sample. If
it's set to False, there will be only split sample in the
final datasets and the original sample will b... |
Initialization method.
:param keep_original_sample: whether to keep the original sample. If
it's set to False, there will be only split sample in the
final datasets and the original sample will be removed. It's True
in default.
:param args: extra args
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_split_by_key_frame_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_split_by_key_frame_mapper.py | Apache-2.0 |
def __init__(self,
detector: str = 'ContentDetector',
threshold: NonNegativeFloat = 27.0,
min_scene_len: NonNegativeInt = 15,
show_progress: bool = False,
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param detector: Algorithm from `scenedetect.detectors`. Should be one
of ['ContentDetector', 'ThresholdDetector', 'AdaptiveDetector`].
:param threshold: Threshold passed to the detector.
:param min_scene_len: Minimum length of any scene.
:par... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_split_by_scene_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_split_by_scene_mapper.py | Apache-2.0 |
def __init__(self,
hf_ast: str = 'MIT/ast-finetuned-audioset-10-10-0.4593',
trust_remote_code: bool = False,
tag_field_name: str = MetaKeys.video_audio_tags,
*args,
**kwargs):
"""
Initialization method.
:param ... |
Initialization method.
:param hf_ast: path to the HF model to tag from audios.
:param trust_remote_code: whether to trust the remote code of HF models
:param tag_field_name: the field name to store the tags. It's
"video_audio_tags" in default.
:param args: extra arg... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_tagging_from_audio_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_tagging_from_audio_mapper.py | Apache-2.0 |
def __init__(self,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
tag_field_name: str = MetaKeys.video_frame_tags,
*args,
**kwargs):
"""
Initialization method.
:param frame_sampling_m... |
Initialization method.
:param frame_sampling_method: sampling method of extracting frame
images from the videos. Should be one of
["all_keyframes", "uniform"].
The former one extracts all key frames (the number of which depends
on the duration of the vid... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/video_tagging_from_frames_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/video_tagging_from_frames_mapper.py | Apache-2.0 |
def __init__(self,
project_name_prefix: str = 'DataJuicer_Annotation',
wait_for_annotations: bool = False,
timeout: int = 3600,
poll_interval: int = 60,
samples_per_task: int = 1,
max_tasks_per_batch: int = 100,
... | Initialize the base annotation operation
Args:
project_name_prefix: Prefix for the project name
project_id: ID of existing project (if None, creates new project)
wait_for_annotations: Whether to wait for annotations to complete
timeout: Maximum time to wait for a... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _handle_task_created(self, data):
"""Handle task created event with notification"""
task_id = data.get('task_id')
sample_ids = data.get('sample_ids', [])
logger.debug(f'Task {task_id} created with {len(sample_ids)} samples')
# Send notification if configured
if self... | Handle task created event with notification | _handle_task_created | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _handle_batch_created(self, data):
"""Handle batch created event with notification"""
batch_id = data.get('batch_id')
task_count = data.get('task_count', 0)
sample_count = data.get('sample_count', 0)
logger.info(
f'Batch {batch_id} created with {task_count} tasks... | Handle batch created event with notification | _handle_batch_created | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _handle_annotation_completed(self, data):
"""Handle annotation completed event with notification"""
task_id = data.get('task_id')
annotation_id = data.get('annotation_id')
logger.debug(
f'Annotation {annotation_id} completed for task {task_id}')
# Mark this task... | Handle annotation completed event with notification | _handle_annotation_completed | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _handle_batch_annotation_completed(self, data):
"""Handle batch annotation completed event with notification"""
batch_id = data.get('batch_id')
task_count = data.get('task_count', 0)
sample_count = data.get('sample_count', 0)
if self.notification_events.get('batch_annotation... | Handle batch annotation completed event with notification | _handle_batch_annotation_completed | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _create_tasks_batch(self, tasks_data: List[Dict],
sample_ids: List[Any]) -> List[int]:
"""Create multiple tasks in the annotation platform
Args:
tasks_data: List of task data
sample_ids: List of sample IDs corresponding to each task
Retur... | Create multiple tasks in the annotation platform
Args:
tasks_data: List of task data
sample_ids: List of sample IDs corresponding to each task
Returns:
List[int]: List of created task IDs
| _create_tasks_batch | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _process_annotation_result(self, annotation: Dict,
sample: Dict) -> Dict:
"""Process annotation result and update the sample
Args:
annotation: The annotation result from the annotation platform
sample: The original sample that was annotated... | Process annotation result and update the sample
Args:
annotation: The annotation result from the annotation platform
sample: The original sample that was annotated
Returns:
Dict: The updated sample with annotation results
| _process_annotation_result | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def process_batched(self, samples):
"""Process a batch of samples by creating annotation tasks
Args:
samples: Dictionary of samples to process (column-oriented)
Returns:
Dict: Processed samples (column-oriented)
"""
# Get dimensions of the data
k... | Process a batch of samples by creating annotation tasks
Args:
samples: Dictionary of samples to process (column-oriented)
Returns:
Dict: Processed samples (column-oriented)
| process_batched | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _create_and_process_batch(self, tasks_data, task_sample_ids):
"""Create a batch of tasks and process the results"""
if not tasks_data:
return
# Generate a batch ID
batch_id = f'batch_{self.batch_counter}_{int(time.time())}'
self.batch_counter += 1
# Flat... | Create a batch of tasks and process the results | _create_and_process_batch | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _wait_for_batch_annotations(self, task_ids=None):
"""Wait for all tasks in a batch to be annotated.
Args:
task_ids: List of task IDs to wait for
Returns:
Dict: Mapping of task IDs to their annotations
"""
if not self.wait_for_annotations or not task_... | Wait for all tasks in a batch to be annotated.
Args:
task_ids: List of task IDs to wait for
Returns:
Dict: Mapping of task IDs to their annotations
| _wait_for_batch_annotations | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def __init__(self,
api_url: str = None,
api_key: str = None,
label_config: Optional[str] = None,
**kwargs):
"""Initialize the Label Studio annotation operation
Args:
api_url: Base URL for Label Studio API
api_ke... | Initialize the Label Studio annotation operation
Args:
api_url: Base URL for Label Studio API
api_key: API key for authentication
label_config: XML configuration for the labeling interface
**kwargs: Additional parameters passed to BaseAnnotationMapper
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def setup_project(self):
"""Create a new project or use existing one"""
try:
# Create new project
logger.info(
f'Creating new Label Studio project: {self.project_name}')
project = self.client.create_project(
title=self.project_name,
... | Create a new project or use existing one | setup_project | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _create_tasks_batch(self, tasks_data: List[Dict],
sample_ids: List[Any]) -> List[int]:
"""Create multiple tasks in Label Studio
Args:
tasks_data: List of task data
sample_ids: List of sample IDs corresponding to each task
Returns:
... | Create multiple tasks in Label Studio
Args:
tasks_data: List of task data
sample_ids: List of sample IDs corresponding to each task
Returns:
List[int]: List of created task IDs
| _create_tasks_batch | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _check_annotation_status(self, task_ids=None):
"""Check the status of annotations for the given task IDs
Args:
task_ids: List of task IDs to check. If None, uses all in batch
Returns:
Tuple[bool, Dict]: (has_changes, completed_tasks_dict)
"""
# Handl... | Check the status of annotations for the given task IDs
Args:
task_ids: List of task IDs to check. If None, uses all in batch
Returns:
Tuple[bool, Dict]: (has_changes, completed_tasks_dict)
| _check_annotation_status | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def _get_task_annotation(self, task_id: int) -> Optional[Dict]:
"""Get annotation for a task if available
Args:
task_id: ID of the task
Returns:
Optional[Dict]: Annotation data or None if not yet annotated
"""
try:
# Get task with annotations... | Get annotation for a task if available
Args:
task_id: ID of the task
Returns:
Optional[Dict]: Annotation data or None if not yet annotated
| _get_task_annotation | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
def get_all_annotations(self) -> Dict[int, Dict]:
"""Get all annotations for tasks created by this operation
Returns:
Dict[int, Dict]: Dictionary mapping task IDs to annotations
"""
task_ids = list(self.task_to_samples.keys())
annotations = {}
for task_id in... | Get all annotations for tasks created by this operation
Returns:
Dict[int, Dict]: Dictionary mapping task IDs to annotations
| get_all_annotations | python | modelscope/data-juicer | data_juicer/ops/mapper/annotation/annotation_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/annotation/annotation_mapper.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.