comparison image_learner.xml @ 11:c5150cceab47 draft

planemo upload for repository https://github.com/goeckslab/gleam.git commit 0fe927b618cd4dfc87af7baaa827034cc6813225
author goeckslab
date Sat, 18 Oct 2025 03:17:09 +0000
parents 9e912fce264c
children bcfa2e234a80
comparison
equal deleted inserted replaced
10:b0d893d04d4c 11:c5150cceab47
5 </requirements> 5 </requirements>
6 <required_files> 6 <required_files>
7 <include path="utils.py" /> 7 <include path="utils.py" />
8 <include path="constants.py" /> 8 <include path="constants.py" />
9 <include path="image_learner_cli.py" /> 9 <include path="image_learner_cli.py" />
10
11 <include path="MetaFormer/metaformer_models.py" />
12 <include path="MetaFormer/metaformer_stacked_cnn.py" />
13 <include path="MetaFormer/__init__.py" />
10 </required_files> 14 </required_files>
11 <stdio> 15 <stdio>
12 <exit_code range="137" level="fatal_oom" description="Out of Memory" /> 16 <exit_code range="137" level="fatal_oom" description="Out of Memory" />
13 <exit_code range="1:" level="fatal" description="Error occurred. Please check Tool Standard Error" /> 17 <exit_code range="1:" level="fatal" description="Error occurred. Please check Tool Standard Error" />
14 </stdio> 18 </stdio>
15 <command> 19 <command>
16 <![CDATA[ 20 <![CDATA[
17 #import re 21 #import re
18
19 #if $input_csv 22 #if $input_csv
20
21 #set $sanitized_input_csv = re.sub('[^\w\-_\.]', '_', $input_csv.element_identifier.strip()) 23 #set $sanitized_input_csv = re.sub('[^\w\-_\.]', '_', $input_csv.element_identifier.strip())
22 ln -sf '$input_csv' "./${sanitized_input_csv}"; 24 ln -sf '$input_csv' "./${sanitized_input_csv}";
23 #end if 25 #end if
24 26
25 python '$__tool_directory__/image_learner_cli.py' 27 python '$__tool_directory__/image_learner_cli.py'
51 #end if 53 #end if
52 #end if 54 #end if
53 #if $augmentation 55 #if $augmentation
54 --augmentation "$augmentation" 56 --augmentation "$augmentation"
55 #end if 57 #end if
58 --image-resize "$image_resize"
56 --random-seed "$random_seed" 59 --random-seed "$random_seed"
57 --output-dir "." && 60 --output-dir "." &&
58 61
59 mkdir -p '$output_model.extra_files_path' && 62 mkdir -p '$output_model.extra_files_path' &&
60 cp -r experiment_run/model/*.json experiment_run/model/model_weights '$output_model.extra_files_path' && 63 cp -r experiment_run/model/*.json experiment_run/model/model_weights '$output_model.extra_files_path' &&
62 echo "Image Learner Classification Experiment is Done!" 65 echo "Image Learner Classification Experiment is Done!"
63 ]]> 66 ]]>
64 </command> 67 </command>
65 68
66 <inputs> 69 <inputs>
67 <param argument="input_csv" type="data" format="csv" optional="false" label="the metadata csv containing image_path column, label column and optional split column" /> 70 <param name="input_csv" argument="input_csv" type="data" format="csv" optional="false" label="the metadata csv containing image_path column, label column and optional split column" />
68 <param name="image_zip" type="data" format="zip" optional="false" label="Image zip" help="Image zip file containing your image data"/> 71 <param name="image_zip" type="data" format="zip" optional="false" label="Image zip" help="Image zip file containing your image data"/>
69 <param name="model_name" type="select" optional="false" label="Select a model for your experiment" > 72 <param name="model_name" type="select" optional="false" label="Select a model for your experiment" >
70 73
71 <option value="resnet18">Resnet18</option> 74 <option value="resnet18">Resnet18</option>
72 <option value="resnet34">Resnet34</option> 75 <option value="resnet34">Resnet34</option>
140 <option value="googlenet">Googlenet</option> 143 <option value="googlenet">Googlenet</option>
141 <option value="inception_v3">Inception_v3</option> 144 <option value="inception_v3">Inception_v3</option>
142 <option value="mobilenet_v2">Mobilenet_v2</option> 145 <option value="mobilenet_v2">Mobilenet_v2</option>
143 <option value="mobilenet_v3_large">Mobilenet_v3_large</option> 146 <option value="mobilenet_v3_large">Mobilenet_v3_large</option>
144 <option value="mobilenet_v3_small">Mobilenet_v3_small</option> 147 <option value="mobilenet_v3_small">Mobilenet_v3_small</option>
148 <!-- MetaFormer Models -->
149 <option value="identityformer_s12">IdentityFormer S12</option>
150 <option value="identityformer_s24">IdentityFormer S24</option>
151 <option value="identityformer_s36">IdentityFormer S36</option>
152 <option value="identityformer_m36">IdentityFormer M36</option>
153 <option value="identityformer_m48">IdentityFormer M48</option>
154 <option value="randformer_s12">RandFormer S12</option>
155 <option value="randformer_s24">RandFormer S24</option>
156 <option value="randformer_s36">RandFormer S36</option>
157 <option value="randformer_m36">RandFormer M36</option>
158 <option value="randformer_m48">RandFormer M48</option>
159 <option value="poolformerv2_s12">PoolFormerV2 S12</option>
160 <option value="poolformerv2_s24">PoolFormerV2 S24</option>
161 <option value="poolformerv2_s36">PoolFormerV2 S36</option>
162 <option value="poolformerv2_m36">PoolFormerV2 M36</option>
163 <option value="poolformerv2_m48">PoolFormerV2 M48</option>
164 <option value="convformer_s18">ConvFormer S18</option>
165 <option value="convformer_s18_384">ConvFormer S18 384</option>
166 <option value="convformer_s18_in21ft1k">ConvFormer S18 ImageNet21k</option>
167 <option value="convformer_s18_384_in21ft1k">ConvFormer S18 384 ImageNet21k</option>
168 <option value="convformer_s18_in21k">ConvFormer S18 ImageNet21k Pretrained</option>
169 <option value="convformer_s36">ConvFormer S36</option>
170 <option value="convformer_s36_384">ConvFormer S36 384</option>
171 <option value="convformer_s36_in21ft1k">ConvFormer S36 ImageNet21k</option>
172 <option value="convformer_s36_384_in21ft1k">ConvFormer S36 384 ImageNet21k</option>
173 <option value="convformer_s36_in21k">ConvFormer S36 ImageNet21k Pretrained</option>
174 <option value="convformer_m36">ConvFormer M36</option>
175 <option value="convformer_m36_384">ConvFormer M36 384</option>
176 <option value="convformer_m36_in21ft1k">ConvFormer M36 ImageNet21k</option>
177 <option value="convformer_m36_384_in21ft1k">ConvFormer M36 384 ImageNet21k</option>
178 <option value="convformer_m36_in21k">ConvFormer M36 ImageNet21k Pretrained</option>
179 <option value="convformer_b36">ConvFormer B36</option>
180 <option value="convformer_b36_384">ConvFormer B36 384</option>
181 <option value="convformer_b36_in21ft1k">ConvFormer B36 ImageNet21k</option>
182 <option value="convformer_b36_384_in21ft1k">ConvFormer B36 384 ImageNet21k</option>
183 <option value="convformer_b36_in21k">ConvFormer B36 ImageNet21k Pretrained</option>
184 <option value="caformer_s18">CAFormer S18</option>
185 <option value="caformer_s18_384">CAFormer S18 384</option>
186 <option value="caformer_s18_in21ft1k">CAFormer S18 ImageNet21k</option>
187 <option value="caformer_s18_384_in21ft1k">CAFormer S18 384 ImageNet21k</option>
188 <option value="caformer_s18_in21k">CAFormer S18 ImageNet21k Pretrained</option>
189 <option value="caformer_s36">CAFormer S36</option>
190 <option value="caformer_s36_384">CAFormer S36 384</option>
191 <option value="caformer_s36_in21ft1k">CAFormer S36 ImageNet21k</option>
192 <option value="caformer_s36_384_in21ft1k">CAFormer S36 384 ImageNet21k</option>
193 <option value="caformer_s36_in21k">CAFormer S36 ImageNet21k Pretrained</option>
194 <option value="caformer_m36">CAFormer M36</option>
195 <option value="caformer_m36_384">CAFormer M36 384</option>
196 <option value="caformer_m36_in21ft1k">CAFormer M36 ImageNet21k</option>
197 <option value="caformer_m36_384_in21ft1k">CAFormer M36 384 ImageNet21k</option>
198 <option value="caformer_m36_in21k">CAFormer M36 ImageNet21k Pretrained</option>
199 <option value="caformer_b36">CAFormer B36</option>
200 <option value="caformer_b36_384">CAFormer B36 384</option>
201 <option value="caformer_b36_in21ft1k">CAFormer B36 ImageNet21k</option>
202 <option value="caformer_b36_384_in21ft1k">CAFormer B36 384 ImageNet21k</option>
203 <option value="caformer_b36_in21k">CAFormer B36 ImageNet21k Pretrained</option>
145 </param> 204 </param>
146 205
147 <conditional name="scratch_fine_tune"> 206 <conditional name="scratch_fine_tune">
148 <param name="use_pretrained" type="select" 207 <param name="use_pretrained" type="select"
149 label="Use pretrained weights?" 208 label="Use pretrained weights?"
160 </when> 219 </when>
161 <when value="false"> 220 <when value="false">
162 <!-- No additional parameters to show if the user selects 'No' --> 221 <!-- No additional parameters to show if the user selects 'No' -->
163 </when> 222 </when>
164 </conditional> 223 </conditional>
224 <param argument="image_resize"
225 name="image_resize"
226 type="select"
227 label="Image Resize"
228 help="Select the size to resize images to. Original size keeps images as-is, while other options resize all images to the specified dimensions.">
229 <option value="original" selected="true">Original Size (No Resize)</option>
230 <option value="96x96">96x96</option>
231 <option value="128x128">128x128</option>
232 <option value="160x160">160x160</option>
233 <option value="192x192">192x192</option>
234 <option value="220x220">220x220</option>
235 <option value="224x224">224x224</option>
236 <option value="256x256">256x256</option>
237 <option value="299x299">299x299</option>
238 <option value="320x320">320x320</option>
239 <option value="384x384">384x384</option>
240 <option value="448x448">448x448</option>
241 <option value="512x512">512x512</option>
242 </param>
165 <param argument="augmentation" 243 <param argument="augmentation"
166 name="augmentation" 244 name="augmentation"
167 type="select" 245 type="select"
168 multiple="true" 246 multiple="true"
169 display="checkboxes" 247 display="checkboxes"
317 <has_n_columns n="1" /> 395 <has_n_columns n="1" />
318 </assert_contents> 396 </assert_contents>
319 </element> 397 </element>
320 </output_collection> 398 </output_collection>
321 </test> 399 </test>
400 <test expect_num_outputs="3">
401 <param name="input_csv" value="mnist_subset.csv" ftype="csv" />
402 <param name="image_zip" value="mnist_subset.zip" ftype="zip" />
403 <param name="model_name" value="caformer_s18" />
404 <output name="output_report">
405 <assert_contents>
406 <has_text text="Results Summary" />
407 <has_text text="Train/Validation Results" />
408 <has_text text="Test Results" />
409 </assert_contents>
410 </output>
411
412 <output_collection name="output_pred_csv" type="list" >
413 <element name="predictions.csv" >
414 <assert_contents>
415 <has_n_columns n="1" />
416 </assert_contents>
417 </element>
418 </output_collection>
419 </test>
420 <test expect_num_outputs="3">
421 <param name="input_csv" value="mnist_subset.csv" ftype="csv" />
422 <param name="image_zip" value="mnist_subset.zip" ftype="zip" />
423 <param name="model_name" value="randformer_s12" />
424 <param name="customize_defaults" value="true" />
425 <param name="epochs" value="5" />
426 <output name="output_report">
427 <assert_contents>
428 <has_text text="Results Summary" />
429 <has_text text="Train/Validation Results" />
430 <has_text text="Test Results" />
431 </assert_contents>
432 </output>
433
434 <output_collection name="output_pred_csv" type="list" >
435 <element name="predictions.csv" >
436 <assert_contents>
437 <has_n_columns n="1" />
438 </assert_contents>
439 </element>
440 </output_collection>
441 </test>
442 <!-- Test 7: MetaFormer with 384x384 input - verifies model correctly handles non-224x224 dimensions -->
443 <test expect_num_outputs="3">
444 <param name="input_csv" value="mnist_subset.csv" ftype="csv" />
445 <param name="image_zip" value="mnist_subset.zip" ftype="zip" />
446 <param name="model_name" value="caformer_s18_384" />
447 <param name="image_resize" value="384x384" />
448 <output name="output_report">
449 <assert_contents>
450 <has_text text="Results Summary" />
451 <has_text text="Train/Validation Results" />
452 <has_text text="Test Results" />
453 </assert_contents>
454 </output>
455 <output_collection name="output_pred_csv" type="list" >
456 <element name="predictions.csv" >
457 <assert_contents>
458 <has_n_columns n="1" />
459 </assert_contents>
460 </element>
461 <element name="description" >
462 <assert_contents>
463 <has_text text="384" />
464 </assert_contents>
465 </element>
466 </output_collection>
467 </test>
468 <!-- Test 8: Binary classification with custom threshold - verifies ROC curve generation for binary tasks; need to find a test dataset -->
469 <!-- <test expect_num_outputs="3">
470 <param name="input_csv" value="binary_classification.csv" ftype="csv" />
471 <param name="image_zip" value="binary_images.zip" ftype="zip" />
472 <param name="model_name" value="resnet18" />
473 <param name="customize_defaults" value="true" />
474 <param name="threshold" value="0.6" />
475 <output name="output_report">
476 <assert_contents>
477 <has_text text="Results Summary" />
478 <has_text text="Train/Validation Results" />
479 <has_text text="Test Results" />
480 <has_text text="ROC-AUC Curves" />
481 </assert_contents>
482 </output>
483 <output_collection name="output_pred_csv" type="list" >
484 <element name="predictions.csv" >
485 <assert_contents>
486 <has_n_columns n="1" />
487 </assert_contents>
488 </element>
489 <element name="test_statistics.json" >
490 <assert_contents>
491 <has_text text="roc_auc" />
492 </assert_contents>
493 </element>
494 </output_collection>
495 </test> -->
496 <!-- Test 9: PoolFormerV2 model configuration - verifies custom_model parameter persists in config -->
497 <test expect_num_outputs="3">
498 <param name="input_csv" value="mnist_subset.csv" ftype="csv" />
499 <param name="image_zip" value="mnist_subset.zip" ftype="zip" />
500 <param name="model_name" value="poolformerv2_s12" />
501 <output name="output_report">
502 <assert_contents>
503 <has_text text="Results Summary" />
504 <has_text text="Train/Validation Results" />
505 <has_text text="Test Results" />
506 </assert_contents>
507 </output>
508 <output_collection name="output_pred_csv" type="list" >
509 <element name="predictions.csv" >
510 <assert_contents>
511 <has_n_columns n="1" />
512 </assert_contents>
513 </element>
514 </output_collection>
515 </test>
516 <!-- Test 10: Multi-class classification with ROC curves - verifies robust ROC-AUC plot generation -->
517 <!-- <test expect_num_outputs="3">
518 <param name="input_csv" value="mnist_subset.csv" ftype="csv" />
519 <param name="image_zip" value="mnist_subset.zip" ftype="zip" />
520 <param name="model_name" value="resnet18" />
521 <param name="customize_defaults" value="true" />
522 <param name="epochs" value="3" />
523 <output name="output_report">
524 <assert_contents>
525 <has_text text="Results Summary" />
526 <has_text text="Train/Validation Results" />
527 <has_text text="Test Results" />
528 <has_text text="ROC-AUC Curves" />
529 <has_text text="Micro-average ROC" />
530 </assert_contents>
531 </output>
532 <output_collection name="output_pred_csv" type="list" >
533 <element name="predictions.csv" >
534 <assert_contents>
535 <has_n_columns n="1" />
536 </assert_contents>
537 </element>
538 </output_collection>
539 </test> -->
322 </tests> 540 </tests>
323 <help> 541 <help>
324 <![CDATA[ 542 <![CDATA[
325 **What it does** 543 **What it does**
326 Image Learner for Classification/regression: trains and evaluates a image classification/regression model. 544 Image Learner for Classification/regression: trains and evaluates a image classification/regression model.
327 It uses the metadata csv to find the image paths and labels. 545 It uses the metadata csv to find the image paths and labels.
328 The metadata csv should contain a column with the name 'image_path' and a column with the name 'label'. 546 The metadata csv should contain a column with the name 'image_path' and a column with the name 'label'.
329 Optionally, you can also add a column with the name 'split' to specify which split each row belongs to (train, val, test). 547 Optionally, you can also add a column with the name 'split' to specify which split each row belongs to (train, val, test).
330 If you do not provide a split column, the tool will automatically split the data into train, val, and test sets based on the proportions you specify or [0.7, 0.1, 0.2] by default. 548 If you do not provide a split column, the tool will automatically split the data into train, val, and test sets based on the proportions you specify or [0.7, 0.1, 0.2] by default.
549
550 **Models Available**
551 This tool supports a wide range of state-of-the-art image classification models including:
552 - Traditional CNNs (ResNet, EfficientNet, VGG, etc.)
553 - Vision Transformers (ViT, Swin Transformer)
554 - Modern architectures (ConvNeXt, MaxViT)
555 - MetaFormer family models (IdentityFormer, RandFormer, PoolFormerV2, ConvFormer, CAFormer)
556
557 **MetaFormer Models**
558 The MetaFormer family represents a unified perspective on transformer-like architectures. These models demonstrate that the success of transformers is largely due to their general architecture rather than specific components like attention mechanisms. All MetaFormer models use pretrained weights from Hugging Face and provide explicit confirmation of weight loading.
331 559
332 **If the selected label column has more than 10 unique values, the tool will automatically treat the task as a regression problem and apply appropriate metrics (e.g., MSE, RMSE, R²).** 560 **If the selected label column has more than 10 unique values, the tool will automatically treat the task as a regression problem and apply appropriate metrics (e.g., MSE, RMSE, R²).**
333 561
334 **Outputs** 562 **Outputs**
335 The tool will output a trained model in the form of a ludwig_model file, 563 The tool will output a trained model in the form of a ludwig_model file,