comparison biapy.xml @ 0:e434d9b9cd13 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/biapy/ commit 66b393a7118c81d86d0fd80780d2bd551c18f3f0
author iuc
date Thu, 09 Oct 2025 07:42:36 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e434d9b9cd13
1 <tool id="biapy" name="Build a workflow with BiaPy" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT">
2 <description>Accessible deep learning on bioimages</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <edam_topics>
7 <edam_topic>topic_3474</edam_topic> <!-- Machine learning -->
8 <!-- <edam_topic>topic_3753</edam_topic> Deep learning (not in EDAM) -->
9 </edam_topics>
10 <edam_operations>
11 <edam_operation>operation_2945</edam_operation> <!-- Image segmentation -->
12 <edam_operation>operation_3925</edam_operation> <!-- Object detection -->
13 <edam_operation>operation_3443</edam_operation> <!-- Image denoising -->
14 <!-- <edam_operation>Single image super-resolution (not in EDAM)</edam_operation> -->
15 <edam_operation>operation_2946</edam_operation> <!-- Image restoration -->
16 <!-- <edam_operation>Image-to-image translation (not in EDAM)</edam_operation> -->
17 <!-- <edam_operation>operation_3442</edam_operation> Image classification -->
18 <!-- <edam_operation>Self-supervision learning (not in EDAM)</edam_operation> -->
19 <edam_operation>operation_2944</edam_operation> <!-- Image analysis -->
20 </edam_operations>
21 <expand macro="requirements" />
22 <required_files>
23 <include path="create_yaml.py" />
24 </required_files>
25 <expand macro="creators" />
26 <command detect_errors="exit_code">
27 <![CDATA[
28 set -xeuo pipefail &&
29 export OPENCV_IO_ENABLE_OPENEXR=0 &&
30
31 ## Define some useful variables
32 #set $train_raw_dir = './dataset/train/raw'
33 #set $train_gt_dir = './dataset/train/gt'
34 #set $test_raw_dir = './dataset/test/raw'
35 #set $test_gt_dir = './dataset/test/gt'
36 #set $generated_cfg = 'generated_config.yaml'
37 #set $checkpoint_dir = './output/my_experiment/checkpoints'
38 #set $checkpoint_file = $checkpoint_dir + '/checkpoint.safetensors'
39 #set $common_yaml_args = " --out_config_path '%s' --biapy_version '@TOOL_VERSION@'" % $generated_cfg
40
41 ## Decide phase and GT availability without touching missing names
42 #set $selected_phase = 'train_test'
43 #set $test_gt_avail = 'test_gt_no'
44
45 #if $mode_selection['selected_mode'] == 'create_new_cfg'
46 #set $selected_phase = $mode_selection['phase_decision']['phases']
47 #if $selected_phase in ['train_test', 'test']
48 #set $test_gt_avail = (
49 $mode_selection['phase_decision'].get('test_sec') and
50 $mode_selection['phase_decision']['test_sec'].get('gt_test')
51 ) and 'test_gt_yes' or 'test_gt_no'
52 #end if
53 #end if
54
55 ## Define output directory
56 mkdir -p output &&
57
58 ## Define checkpoint directory in case it is needed
59 mkdir -p '$checkpoint_dir' &&
60
61 ########## Reuse provided yaml file and update paths ##########
62 #if $mode_selection.selected_mode == 'custom_cfg':
63 #if $mode_selection.get('test_sec') and $mode_selection['test_sec'].get('gt_test'):
64 #set $test_gt_avail = 'test_gt_yes'
65 #end if
66 #set $mpath = $mode_selection.get('biapy_model_path')
67 #if $mpath and str($mpath) not in ['None', '']
68 ln -fs '$mpath' ${checkpoint_file} &&
69 #end if
70 python '$__tool_directory__/create_yaml.py'
71 --input_config_path '$mode_selection.config_path'
72 ${common_yaml_args}
73 ## Optionally override data paths with the staged dirs if user provided inputs
74 #if $selected_phase in ['train_test', 'train'] and $mode_selection.get('train_sec') and $mode_selection['train_sec'].get('raw_train')
75 --raw_train '$train_raw_dir'
76 #if $mode_selection['train_sec'].get('gt_train')
77 --gt_train '$train_gt_dir'
78 #end if
79 #end if
80 #if $selected_phase in ['train_test', 'test'] and $mode_selection.get('test_sec') and $mode_selection['test_sec'].get('raw_test')
81 --test_raw_path '$test_raw_dir'
82 #if $test_gt_avail == 'test_gt_yes' and $mode_selection['test_sec'].get('gt_test')
83 --test_gt_path '$test_gt_dir'
84 #end if
85 #end if
86 #if $mpath and str($mpath) not in ['None', '']
87 --model '$checkpoint_file'
88 --model_source 'biapy'
89 #end if
90 #else
91 ########## Create new yaml file ##########
92 #set $pm = $mode_selection["pretrained_model"]
93 python '$__tool_directory__/create_yaml.py'
94 --new_config
95 ${common_yaml_args}
96 --workflow '$mode_selection["workflow"]'
97 --dims '$mode_selection["dimensionality"]["is_3d"]'
98 --obj_slices '$mode_selection["dimensionality"].get("obj_slices")'
99 --obj_size '$mode_selection["obj_size"]'
100 --img_channel '$mode_selection["img_channel"]'
101 #if $pm["model_source"] == 'biapy'
102 --model_source 'biapy'
103 #elif $pm["model_source"] == 'biapy_pretrained'
104 --model '$checkpoint_file'
105 --model_source 'biapy'
106 #elif $pm.get("model_source") == 'bmz_torchvision' and $pm.get("bmz_torchvision_model")
107 #set $bt = $pm["bmz_torchvision_model"].get("bmz_or_torchvision", "")
108 #if $bt == 'bmz'
109 --model_source 'bmz'
110 --model '$pm["bmz_torchvision_model"].get("bmz_model_name", "")'
111 #else
112 --model_source 'torchvision'
113 --model '$pm["bmz_torchvision_model"].get("torchvision_model_name", "")'
114 #end if
115 #end if
116 #if $selected_phase == 'train_test'
117 --raw_train '$train_raw_dir'
118 --gt_train '$train_gt_dir'
119 --test_raw_path '$test_raw_dir'
120 #if $test_gt_avail == 'test_gt_yes'
121 --test_gt_path '$test_gt_dir'
122 #end if
123 #elif $selected_phase == 'train'
124 --raw_train '$train_raw_dir'
125 --gt_train '$train_gt_dir'
126 #elif $selected_phase == 'test'
127 --test_raw_path '$test_raw_dir'
128 #if $test_gt_avail == 'test_gt_yes'
129 --test_gt_path '$test_gt_dir'
130 #end if
131 #end if
132
133 #if $pm["model_source"] == 'biapy_pretrained'
134 && ln -fs '$pm["biapy_model_path"]' ${checkpoint_file}
135 #end if
136 #end if
137
138 &&
139
140 ## Copy the training data
141 #if $selected_phase in ['train_test', 'train']:
142 mkdir -p '$train_raw_dir' &&
143 #for $i, $image in enumerate($raw_train)
144 #set $ext = $image.ext
145 ln -s '$image' ${train_raw_dir}/training-${i}.${ext} &&
146 #end for
147 mkdir -p '$train_gt_dir' &&
148 #for $i, $image in enumerate($gt_train)
149 #set $ext = $image.ext
150 ln -s '$image' ${train_gt_dir}/training-gt-${i}.${ext} &&
151 #end for
152 #end if
153
154 ## Copy the test data
155 #if $selected_phase in ['train_test', 'test']:
156 mkdir -p '$test_raw_dir' &&
157 #for $i, $image in enumerate($raw_test)
158 #set $ext = $image.ext
159 ln -s '$image' ${test_raw_dir}/test-${i}.${ext} &&
160 #end for
161 #if $test_gt_avail == 'test_gt_yes':
162 mkdir -p '$test_gt_dir' &&
163 #for $i, $image in enumerate($gt_test)
164 #set $ext = $image.ext
165 ln -s '$image' ${test_gt_dir}/test-gt-${i}.${ext} &&
166 #end for
167 #end if
168 #end if
169
170 ########## Run BiaPy ##########
171 biapy
172 --config '$generated_cfg'
173 --result_dir './output'
174 --name 'my_experiment'
175 --run_id 1
176 --gpu \${GALAXY_BIAPY_GPU_STRING:-""}
177
178 #set $outs = $selected_outputs or []
179
180 ## Copy the selected output to the correct place
181 #if $selected_phase in ['train_test', 'test']:
182
183 #if 'raw' in $outs
184 ########
185 ## RAW #
186 ########
187 && mkdir -p raw && {
188 ## Instance segmentation
189 if [ -d "output/my_experiment/results/my_experiment_1/per_image_instances" ]; then
190 mv output/my_experiment/results/my_experiment_1/per_image_instances/* raw/;
191
192 ## Instance segmentation
193 elif [ -d "output/my_experiment/results/my_experiment_1/full_image_instances" ]; then
194 mv output/my_experiment/results/my_experiment_1/full_image_instances/* raw/;
195
196 ## Semantic segmentation
197 elif [ -d "output/my_experiment/results/my_experiment_1/per_image_binarized" ]; then
198 mv output/my_experiment/results/my_experiment_1/per_image_binarized/* raw/;
199
200 ## Semantic segmentation
201 elif [ -d "output/my_experiment/results/my_experiment_1/full_image_binarized" ]; then
202 mv output/my_experiment/results/my_experiment_1/full_image_binarized/* raw/;
203
204 ## I2I
205 elif [ -d "output/my_experiment/results/my_experiment_1/full_image" ]; then
206 mv output/my_experiment/results/my_experiment_1/full_image/* raw/;
207
208 ## Detection
209 elif [ -d "output/my_experiment/results/my_experiment_1/per_image_local_max_check" ]; then
210 mv output/my_experiment/results/my_experiment_1/per_image_local_max_check/* raw/;
211
212 ## Detection, Denoising, I2I, SSL, SR
213 elif [ -d "output/my_experiment/results/my_experiment_1/per_image" ]; then
214 mv output/my_experiment/results/my_experiment_1/per_image/* raw/;
215
216 ## Classification
217 elif [ -f "output/my_experiment/results/my_experiment_1/predictions.csv" ]; then
218 mv output/my_experiment/results/my_experiment_1/predictions.csv raw/;
219 fi;
220 }
221 #end if
222
223 #if 'post_proc' in $outs
224 ##############
225 ## POST-PROC #
226 ##############
227 && mkdir -p post_proc && {
228 ## Instance segmentation
229 if [ -d "output/my_experiment/results/my_experiment_1/per_image_post_processing" ]; then
230 mv output/my_experiment/results/my_experiment_1/per_image_post_processing/* post_proc/;
231
232 ## Instance segmentation
233 elif [ -d "output/my_experiment/results/my_experiment_1/full_image_post_processing" ]; then
234 mv output/my_experiment/results/my_experiment_1/full_image_post_processing/* post_proc/;
235
236 ## Detection
237 elif [ -d "output/my_experiment/results/my_experiment_1/per_image_local_max_check_post_proc" ]; then
238 mv output/my_experiment/results/my_experiment_1/per_image_local_max_check_post_proc/* post_proc/;
239 fi;
240 }
241 #end if
242
243 #if 'metrics' in $outs and $test_gt_avail == "test_gt_yes":
244 && mkdir -p metrics &&
245 mv output/my_experiment/results/my_experiment_1/test_results_metrics.csv metrics/ 2>/dev/null || true
246 #end if
247 #end if
248 #if $selected_phase in ['train_test', 'train']:
249 #if 'tcharts' in $outs
250 && mkdir -p train_charts
251 #end if
252 #if 'tlogs' in $outs
253 && mkdir -p train_logs
254 #end if
255 #end if
256 #if 'checkpoint' in $outs
257 && mkdir -p checkpoints
258 #end if
259 ]]>
260 </command>
261
262 <inputs>
263 <conditional name="mode_selection">
264 <param name="selected_mode" type="select" label="Do you have a configuration file?">
265 <option value="custom_cfg" selected="true">
266 Yes, I already have one and I want to run BiaPy directly.
267 </option>
268 <option value="create_new_cfg">
269 No, I want to create one from scratch.
270 </option>
271 </param>
272 <when value="custom_cfg">
273 <param name="config_path" type="data" format="yaml" optional="false" label="Select a configuration file" help="Input configuration file"/>
274 <param name="biapy_model_path" type="data" format="safetensors" optional="true" label="Select the model checkpoint (if needed)" help="Path to a pre-trained model checkpoint (.safetensors) generated by BiaPy. Use this only if 'MODEL.LOAD_CHECKPOINT' is set to 'True' in your configuration."/>
275 <section name="train_sec" title="If train is enabled select the training images">
276 <!-- Q9 -->
277 <expand macro="train_raw_param_opt"/>
278 <!-- Q10 -->
279 <expand macro="train_gt_param_opt"/>
280 </section>
281 <section name="test_sec" title="If test is enabled select the test images">
282 <!-- Q11 -->
283 <expand macro="test_raw_param_opt"/>
284 <!-- Q13 -->
285 <expand macro="test_gt_param_optional"/>
286 </section>
287 </when>
288 <when value="create_new_cfg">
289 <conditional name="dimensionality">
290 <!-- Q1 -->
291 <param name="is_3d" type="select" label="Are your images in 3D?" help="Select the type of images you will use: 'No' = 2D images (e.g. (512, 1024, 2)); 'Yes' = 3D images (e.g. (400, 400, 50, 1)); 'No, but output as 3D stack' = process 2D images and combine them into a 3D stack after inference, useful if 2D slices form a larger 3D volume.">
292 <option value="2d" selected="true">No</option>
293 <option value="3d">Yes</option>
294 <option value="2d_stack">No, but I would like to have a 3D stack output</option>
295 </param>
296 <when value="3d">
297 <!-- Q7 -->
298 <param name="obj_slices" type="select" label="How many slices can an object be represented in?" help="This parameter defines the approximate size of the objects of interest along the Z axis. For example, in nucleus segmentation it refers to how many slices a nucleus spans in the stack; knowing this helps set an appropriate value.">
299 <option value="1-5" selected="true">1-5 slices</option>
300 <option value="5-10">5-10 slices</option>
301 <option value="10-20">10-20 slices</option>
302 <option value="20-60">20-60 slices</option>
303 <option value="60+">More than 60 slices</option>
304 </param>
305 </when>
306 <when value="2d"/>
307 <when value="2d_stack"/>
308 </conditional>
309 <!-- Q6 -->
310 <param name="obj_size" type="select" label="What is the average object width/height in pixels?" help="This parameter defines the approximate size of the objects of interest in your images; for example, in nucleus segmentation it refers to the typical size of nuclei, and only a rough estimation is needed.">
311 <option value="0-25" selected="true">0-25 px</option>
312 <option value="25-100">25-100 px</option>
313 <option value="100-200">100-200 px</option>
314 <option value="200-500">200-500 px</option>
315 <option value="500+">More than 500 px</option>
316 </param>
317 <param name="img_channel" type="integer" value="1" min="1" max="10" label="Input the number of channels of the images" help="This parameter specifies the number of channels in your images; for example, use 3 for RGB images or 1 for grayscale, so the model can correctly interpret the input data."/>
318
319 <!-- Q2 -->
320 <param name="workflow" type="select" label="Do you want to:" help="Select a workflow to run; see https://biapy.readthedocs.io/en/latest/get_started/select_workflow.html for further explanation.">
321 <option value="semantic" selected="true">Generate masks of different (or just one) objects/regions within the image</option>
322 <option value="instance">Generate masks for each object in the image</option>
323 <option value="detection">Identify and count roughly circular objects in the images, without needing an exact outline around each one</option>
324 <option value="denoising">Clean noisy images</option>
325 <option value="sr">Upsample images into higher resolution</option>
326 <option value="cls">Assign a label to each image</option>
327 <option value="sr2">Restore a degraded image</option>
328 <option value="i2i">Generate new images based on an input one</option>
329 </param>
330
331 <conditional name="pretrained_model">
332 <!-- Q3 -->
333 <param name="model_source" type="select" label="Do you want to use a pre-trained model?" help="This parameter defines how the deep learning model will be built: (1) build from scratch based on the workflow and image size, (2) load a model previously trained in BiaPy (checkpoint .safetensors in the results/checkpoints folder), or (3) load a pre-trained model from external sources such as the BioImage Model Zoo or Torchvision; training requires labeled data, but pre-trained models can save time and improve results if they match your task.">
334 <option value="biapy" selected="true">No, I want to build a model from scratch</option>
335 <option value="biapy_pretrained">Yes, I have a model previously trained in BiaPy</option>
336 <option value="bmz_torchvision">Yes, I want to check if there is a pre-trained model I can use</option>
337 </param>
338 <when value="biapy_pretrained">
339 <!-- Q4 -->
340 <param name="biapy_model_path" type="data" format="data" optional="false" label="Select the model trained with BiaPy before" help="Select a pre-trained BiaPy model checkpoint (.safetensors) to use for inference or to resume training. Checkpoints are typically generated by previous BiaPy training runs and appear in your Galaxy history as output datasets."/>
341 </when>
342 <when value="bmz_torchvision">
343 <!-- Q5 -->
344 <conditional name="bmz_torchvision_model">
345 <param name="bmz_or_torchvision" type="select" label="Which is the source of the model?" help="Enter the source of the model, whether if it is available through the BioImage Model Zoo or TorchVision">
346 <option value="bmz" selected="true">BioImage Model Zoo</option>
347 <option value="torchvision">TorchVision</option>
348 </param>
349 <when value="bmz">
350 <param name="bmz_model_name" type="text" optional="false" value="sensible-cat" label="BioImage Model Zoo model name" help="Enter the name of a pre-trained model from the BioImage Model Zoo (https://bioimage.io/#/models); filter by the BiaPy icon and ensure the model matches your dimensionality (2D/3D) and task (e.g. semantic segmentation).">
351 <validator type="regex" message="Use an adjective-noun pattern like 'sensible-cat' (letters and dashes only).">^[A-Za-z]+(?:-[A-Za-z]+)+$</validator>
352 </param>
353 </when>
354 <when value="torchvision">
355 <param name="torchvision_model_name" type="text" optional="false" label="TorchVision model name" help="Enter the name of a pre-trained model from TorchVision (see https://docs.pytorch.org/vision/0.21/models.html#general-information-on-pre-trained-weights), e.g. 'alexnet' for classification.">
356 <validator type="regex" message="Only letters, digits, underscores and dots; must start with a letter.">^[a-zA-Z][a-zA-Z0-9_\.]*$</validator>
357 </param>
358 </when>
359 </conditional>
360 </when>
361 <when value="biapy"/>
362 </conditional>
363
364 <conditional name="phase_decision">
365 <!-- Q8 -->
366 <param name="phases" type="select" label="What do you want to do?" help="Select which workflow phases to run: training (fit the model to labeled data) and/or testing (inference/prediction on new images using the trained model).">
367 <option value="train_test" selected="true">Train and test a model</option>
368 <option value="train">Train a model</option>
369 <option value="test">Test a model</option>
370 </param>
371 <when value="train_test">
372 <section name="train_sec" title="Train data" expanded="True">
373 <!-- Q9 -->
374 <expand macro="train_raw_param"/>
375 <!-- Q10 -->
376 <expand macro="train_gt_param"/>
377 </section>
378 <section name="test_sec" title="Test data" expanded="True">
379 <!-- Q11 -->
380 <expand macro="test_raw_param"/>
381 <!-- Optional test GT -->
382 <expand macro="test_gt_param_optional"/>
383 </section>
384 </when>
385
386 <when value="train">
387 <section name="train_sec" title="Train data" expanded="True">
388 <!-- Q9 -->
389 <expand macro="train_raw_param"/>
390 <!-- Q10 -->
391 <expand macro="train_gt_param"/>
392 </section>
393 </when>
394
395 <when value="test">
396 <section name="test_sec" title="Test data" expanded="True">
397 <!-- Q11 -->
398 <expand macro="test_raw_param"/>
399 <!-- Optional test GT -->
400 <expand macro="test_gt_param_optional"/>
401 </section>
402 </when>
403 </conditional>
404 </when>
405 </conditional>
406 <param name="selected_outputs" type="select" display="checkboxes" multiple="true" label="Select the outputs" help="Select which outputs to generate from running BiaPy (e.g. predictions, metrics, logs, or intermediate results).">
407 <option value="raw" selected="true">Test predictions (if exist)</option>
408 <option value="post_proc">Post-processed test predictions (if exist)</option>
409 <option value="metrics">Evaluation metrics (if exist, on test data)</option>
410 <option value="tcharts">Training charts (if exist)</option>
411 <option value="tlogs">Training logs (if exist)</option>
412 <option value="checkpoint">Model checkpoint</option>
413 </param>
414
415 </inputs>
416
417 <outputs>
418 <collection name="predictions_raw" type="list" label="${tool.name} on ${on_string}: Test predictions">
419 <discover_datasets directory="raw" pattern="(?P&lt;designation&gt;.+)\.tif" format="tif" recurse="false"/>
420 <discover_datasets directory="raw" pattern="(?P&lt;designation&gt;.+)\.tiff" format="tiff" recurse="false"/>
421 <discover_datasets directory="raw" pattern="(?P&lt;designation&gt;.+)\.csv" format="csv" recurse="false"/>
422 <discover_datasets directory="raw" pattern="(?P&lt;designation&gt;.+)\.h5" format="h5" recurse="false"/>
423 <filter><![CDATA[
424 'raw' in selected_outputs and (
425 (mode_selection['selected_mode'] == 'create_new_cfg' and
426 mode_selection['phase_decision']['phases'] in ['test','train_test'])
427 or
428 (mode_selection['selected_mode'] == 'custom_cfg')
429 )
430 ]]></filter>
431 </collection>
432
433 <collection name="predictions_post_proc" type="list" label="${tool.name} on ${on_string}: Post-processed test predictions">
434 <discover_datasets directory="post_proc" pattern="(?P&lt;designation&gt;.+)\.tif" format="tif" recurse="false" />
435 <discover_datasets directory="post_proc" pattern="(?P&lt;designation&gt;.+)\.tiff" format="tiff" recurse="false"/>
436 <discover_datasets directory="post_proc" pattern="(?P&lt;designation&gt;.+)\.csv" format="csv" recurse="false"/>
437 <discover_datasets directory="post_proc" pattern="(?P&lt;designation&gt;.+)\.h5" format="h5" recurse="false" />
438 <filter><![CDATA[
439 'post_proc' in selected_outputs and (
440 (mode_selection['selected_mode'] == 'create_new_cfg' and
441 mode_selection['phase_decision']['phases'] in ['test','train_test'])
442 or
443 (mode_selection['selected_mode'] == 'custom_cfg')
444 )
445 ]]>
446 </filter>
447 </collection>
448
449 <collection name="test_metrics" type="list" label="${tool.name} on ${on_string}: Test metrics">
450 <discover_datasets directory="metrics" pattern="(?P&lt;designation&gt;.+)\.csv" format="csv" recurse="false" />
451 <filter><![CDATA[
452 'metrics' in selected_outputs and (
453 (mode_selection['selected_mode'] == 'create_new_cfg' and
454 mode_selection['phase_decision']['phases'] in ['test','train_test'] and
455 mode_selection['phase_decision'].get('test_sec') and
456 mode_selection['phase_decision']['test_sec'].get('gt_test'))
457 or
458 (mode_selection['selected_mode'] == 'custom_cfg')
459 )
460 ]]>
461 </filter>
462 </collection>
463
464 <collection name="train_charts" type="list" label="${tool.name} on ${on_string}: Training charts">
465 <discover_datasets directory="output/my_experiment/results/my_experiment_1/charts" pattern="(?P&lt;designation&gt;.+)\.png" format="png" recurse="false" />
466 <filter><![CDATA[
467 'tcharts' in selected_outputs and (
468 (mode_selection['selected_mode'] == 'create_new_cfg' and
469 mode_selection['phase_decision']['phases'] in ['train','train_test'])
470 or
471 (mode_selection['selected_mode'] == 'custom_cfg')
472 )
473 ]]>
474 </filter>
475 </collection>
476
477 <collection name="train_logs" type="list" label="${tool.name} on ${on_string}: Training logs">
478 <discover_datasets directory="output/my_experiment/train_logs" pattern="(?P&lt;designation&gt;.+)\.txt" format="txt" recurse="false" />
479 <filter><![CDATA[
480 'tlogs' in selected_outputs and (
481 (mode_selection['selected_mode'] == 'create_new_cfg' and
482 mode_selection['phase_decision']['phases'] in ['train','train_test'])
483 or
484 (mode_selection['selected_mode'] == 'custom_cfg')
485 )
486 ]]>
487 </filter>
488 </collection>
489
490 <collection name="model_checkpoint" type="list" label="${tool.name} on ${on_string}: Model checkpoint">
491 <discover_datasets pattern="(?P&lt;designation&gt;.+)\.safetensors" format="data" directory="output/my_experiment/checkpoints" recurse="false" />
492 <filter><![CDATA[
493 'checkpoint' in selected_outputs
494 ]]>
495 </filter>
496 </collection>
497 </outputs>
498 <tests>
499 <!-- test1: test with custom cfg -->
500 <test expect_num_outputs="2">
501 <!-- Choose the conditional branch -->
502 <param name="mode_selection|selected_mode" value="custom_cfg"/>
503
504 <param name="mode_selection|config_path" value="example.yaml"/>
505 <param name="mode_selection|test_sec|raw_test" value="im_0000.png"/>
506 <param name="mode_selection|test_sec|gt_test" value="mask_0000.png"/>
507 <param name="selected_outputs" value="raw,metrics"/>
508 <output_collection name="predictions_raw" type="list" count="1" />
509 <output_collection name="test_metrics" type="list" count="1"/>
510 <assert_command>
511 <has_text text="--config 'generated_config.yaml'"/>
512 <has_text text="--result_dir './output'"/>
513 <has_text text="--name 'my_experiment'"/>
514 <has_text text="--run_id 1"/>
515 </assert_command>
516 </test>
517
518 <!-- test2: create_new_cfg using a model from the zoo -->
519 <test expect_num_outputs="2">
520 <!-- Top-level branch -->
521 <param name="mode_selection|selected_mode" value="create_new_cfg" />
522
523 <!-- Dimensionality (Q1) -->
524 <param name="mode_selection|dimensionality|is_3d" value="2d" />
525
526 <!-- Object size (Q6) & channels -->
527 <param name="mode_selection|obj_size" value="0-25" />
528 <param name="mode_selection|img_channel" value="1" />
529
530 <!-- Workflow (Q2) -->
531 <param name="mode_selection|workflow" value="semantic" />
532
533 <!-- Pretrained model (Q3, Q5) -->
534 <param name="mode_selection|pretrained_model|model_source" value="bmz_torchvision" />
535 <param name="mode_selection|pretrained_model|bmz_torchvision_model|bmz_or_torchvision" value="bmz" />
536 <param name="mode_selection|pretrained_model|bmz_torchvision_model|bmz_model_name" value="sensible-cat" />
537
538 <!-- Phase decision (Q8) -->
539 <param name="mode_selection|phase_decision|phases" value="test" />
540
541 <!-- Test data (Q11/Q12/Q13) -->
542 <param name="mode_selection|phase_decision|test_sec|raw_test" value="im_0000.png" />
543 <param name="mode_selection|phase_decision|test_sec|gt_test" value="mask_0000.png" />
544
545 <!-- Outputs to check -->
546 <param name="selected_outputs" value="raw,metrics" />
547 <output_collection name="predictions_raw" type="list" count="1" />
548 <output_collection name="test_metrics" type="list" count="1"/>
549 <assert_command>
550 <has_text text="--config 'generated_config.yaml'"/>
551 <has_text text="--result_dir './output'"/>
552 <has_text text="--name 'my_experiment'"/>
553 <has_text text="--run_id 1"/>
554 </assert_command>
555 </test>
556
557 <!-- test3: create_new_cfg to use a denoising workflow -->
558 <test expect_num_outputs="1">
559 <!-- Top-level branch -->
560 <param name="mode_selection|selected_mode" value="create_new_cfg" />
561
562 <!-- Dimensionality (Q1) -->
563 <param name="mode_selection|dimensionality|is_3d" value="2d" />
564
565 <!-- Object size (Q6) & channels -->
566 <param name="mode_selection|obj_size" value="25-100" />
567 <param name="mode_selection|img_channel" value="1" />
568
569 <!-- Workflow (Q2) -->
570 <param name="mode_selection|workflow" value="denoising" />
571
572 <!-- Model from scratch (Q3) -->
573 <param name="mode_selection|pretrained_model|model_source" value="biapy" />
574
575 <!-- Phase decision (Q8) -->
576 <param name="mode_selection|phase_decision|phases" value="test" />
577
578 <!-- Test data (Q11) -->
579 <param name="mode_selection|phase_decision|test_sec|raw_test" value="im_0000.png" />
580
581 <!-- Outputs to check -->
582 <param name="selected_outputs" value="raw" />
583 <output_collection name="predictions_raw" type="list" count="1" />
584 <assert_command>
585 <has_text text="--config 'generated_config.yaml'"/>
586 <has_text text="--result_dir './output'"/>
587 <has_text text="--name 'my_experiment'"/>
588 <has_text text="--run_id 1"/>
589 </assert_command>
590 </test>
591
592 </tests>
593 <help><![CDATA[
594 **What it does**
595
596 This tool runs a BiaPy workflow for image analysis using deep learning models. BiaPy is a bioimage analysis pipeline designed to simplify training, prediction, and evaluation across a variety of tasks such as image segmentation, classification, denoising, and more.
597
598 ---
599
600 **Usage**
601
602 There are two main usage modes for this tool:
603
604 1. **Using a custom configuration file (YAML)**
605 If you already have a BiaPy configuration file, you can upload it directly. The tool will use this configuration without further modification to run the specified BiaPy workflow.
606
607 2. **Constructing a configuration interactively**
608 If you do not have a YAML configuration file, the tool can help you build one by asking a set of guided questions. This includes settings like:
609 - Task type (e.g., segmentation, classification)
610 - Model architecture
611 - Input/output patch sizes
612 - Data paths and formats
613 - Training parameters (epochs, batch size, etc.)
614
615 Once these options are specified, the tool generates a valid BiaPy YAML config and proceeds to execute the workflow.
616
617 ---
618
619 **Output**
620
621 The output depends on the chosen workflow and may include:
622 - Trained model weights
623 - Prediction results
624 - Evaluation metrics (if ground truth is available)
625 - Log files and training history
626
627 ---
628
629 **Tips**
630
631 - For best results, ensure that your input data format matches what BiaPy expects. Refer to the [BiaPy documentation](https://biapy.readthedocs.io/en/latest/) for details.
632 - Use the "interactive mode" if you're new to BiaPy and want guidance on configuration.
633 - Advanced users with pre-tuned configs may prefer uploading a YAML directly for faster execution.
634
635 ---
636
637 **References**
638 - BiaPy landing page: https://biapyx.github.io/
639 - BiaPy documentation: https://biapy.readthedocs.io/
640 - Galaxy Tool Development: https://galaxyproject.org/tools/
641 ]]></help>
642 <expand macro="citations"/>
643 </tool>