Skip to content

Commit

Permalink
Multi-modal initial assumption fix (#1357)
Browse files Browse the repository at this point in the history
* Multi-modal initial assumption fix
* Test for multi-modal composing added
  • Loading branch information
nicl-nno authored Jan 15, 2025
1 parent 84f4ebb commit 94a661e
Show file tree
Hide file tree
Showing 33 changed files with 18,144 additions and 3 deletions.
8 changes: 6 additions & 2 deletions examples/advanced/multi_modal_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def prepare_multi_modal_data(files_path: str, task: Task, images_size: tuple = (
"""

path = os.path.join(str(fedot_project_root()), files_path)

if not os.path.exists(path):
raise FileNotFoundError(path)

# unpacking of data archive
unpack_archived_data(path)
# import of table data
Expand Down Expand Up @@ -68,15 +72,15 @@ def prepare_multi_modal_data(files_path: str, task: Task, images_size: tuple = (
return data


def run_multi_modal_pipeline(files_path: str, visualization=False) -> float:
def run_multi_modal_pipeline(files_path: str, timeout=15, visualization=False) -> float:
task = Task(TaskTypesEnum.classification)
images_size = (224, 224)

data = prepare_multi_modal_data(files_path, task, images_size)

fit_data, predict_data = train_test_data_setup(data, shuffle=True, split_ratio=0.6)

automl_model = Fedot(problem='classification', timeout=15)
automl_model = Fedot(problem='classification', timeout=timeout)
pipeline = automl_model.fit(features=fit_data,
target=fit_data.target)

Expand Down
6 changes: 6 additions & 0 deletions fedot/api/api_utils/assumptions/assumptions_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def to_builders(self, initial_node: Optional[PipelineNode] = None,
data_pipeline_alternatives = subbuilder.build(first_node, use_input_preprocessing=use_input_preprocessing)
subpipelines.append(data_pipeline_alternatives)

# TODO: fix this workaround during the improvement of multi-modality
for i, subpipeline in enumerate(subpipelines):
if (len(subpipeline) == 1 and len(subpipeline[0].nodes) == 1 and
str(subpipeline[0].nodes[0]) in ['cnn', 'data_source_img']):
subpipelines[i] = [Pipeline(PipelineNode('cnn', nodes_from=[PipelineNode('data_source_img')]))]

# Then zip these alternatives together and add final node to get ensembles.
ensemble_builders: List[PipelineBuilder] = []
for pre_ensemble in zip(*subpipelines):
Expand Down
5 changes: 4 additions & 1 deletion fedot/core/pipelines/tuning/tuner_builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from datetime import timedelta
from typing import Iterable, Sequence, Type, Union

from golem.core.tuning.iopt_tuner import IOptTuner
try:
from golem.core.tuning.iopt_tuner import IOptTuner
except ModuleNotFoundError:
print('IOpt tuner not installed')
from golem.core.tuning.optuna_tuner import OptunaTuner
from golem.core.tuning.simultaneous import SimultaneousTuner
from golem.core.tuning.tuner_interface import BaseTuner
Expand Down
Binary file modified test/data/multi_modal/1951261.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/multi_modal/1951264.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/multi_modal/1951265.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/data/multi_modal/1975158.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 94a661e

Please sign in to comment.