MCPcopy Create free account
hub / github.com/modelscope/modelscope / find_field_by_task

Method find_field_by_task

modelscope/utils/constant.py:331–363  ·  view source on GitHub ↗
(task_name)

Source from the content-addressed store, hash-verified

329
330 @staticmethod
331 def find_field_by_task(task_name):
332 if len(Tasks.reverse_field_index) == 0:
333 # Lazy init, not thread safe
334 field_dict = {
335 Fields.cv: [
336 getattr(Tasks, attr) for attr in dir(CVTasks)
337 if not attr.startswith('__')
338 ],
339 Fields.nlp: [
340 getattr(Tasks, attr) for attr in dir(NLPTasks)
341 if not attr.startswith('__')
342 ],
343 Fields.audio: [
344 getattr(Tasks, attr) for attr in dir(AudioTasks)
345 if not attr.startswith('__')
346 ],
347 Fields.multi_modal: [
348 getattr(Tasks, attr) for attr in dir(MultiModalTasks)
349 if not attr.startswith('__')
350 ],
351 Fields.science: [
352 getattr(Tasks, attr) for attr in dir(ScienceTasks)
353 if not attr.startswith('__')
354 ],
355 }
356
357 for field, tasks in field_dict.items():
358 for task in tasks:
359 if task in Tasks.reverse_field_index:
360 raise ValueError(f'Duplicate task: {task}')
361 Tasks.reverse_field_index[task] = field
362
363 return Tasks.reverse_field_index.get(task_name)
364
365
366class InputFields(object):

Callers 2

to_custom_datasetMethod · 0.80
from_pretrainedMethod · 0.80

Calls 2

itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected