Mercurial > repos > goeckslab > image_learner
comparison image_learner.xml @ 0:54b871dfc51e draft
planemo upload for repository https://github.com/goeckslab/gleam.git commit b7411ff35b6228ccdfd36cd4ebd946c03ac7f7e9
| author | goeckslab |
|---|---|
| date | Tue, 03 Jun 2025 21:22:11 +0000 |
| parents | |
| children | 39202fe5cf97 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:54b871dfc51e |
|---|---|
| 1 <tool id="image_learner" name="Image Learner for Classification" version="0.1.0" profile="22.05"> | |
| 2 <description>trains and evaluates a image classification model</description> | |
| 3 <requirements> | |
| 4 <container type="docker">quay.io/goeckslab/galaxy-ludwig-gpu:0.10.1</container> | |
| 5 </requirements> | |
| 6 <required_files> | |
| 7 <include path="utils.py" /> | |
| 8 <include path="image_learner_cli.py" /> | |
| 9 </required_files> | |
| 10 <stdio> | |
| 11 <exit_code range="137" level="fatal_oom" description="Out of Memory" /> | |
| 12 <exit_code range="1:" level="fatal" description="Error occurred. Please check Tool Standard Error" /> | |
| 13 </stdio> | |
| 14 <command> | |
| 15 <![CDATA[ | |
| 16 #import re | |
| 17 | |
| 18 #if $input_csv | |
| 19 | |
| 20 #set $sanitized_input_csv = re.sub('[^\w\-_\.]', '_', $input_csv.element_identifier.strip()) | |
| 21 ln -sf '$input_csv' "./${sanitized_input_csv}"; | |
| 22 #end if | |
| 23 | |
| 24 python '$__tool_directory__/image_learner_cli.py' | |
| 25 --csv-file "./${sanitized_input_csv}" | |
| 26 --image-zip "$image_zip" | |
| 27 --model-name "$model_name" | |
| 28 #if $use_pretrained == "true" | |
| 29 --use-pretrained | |
| 30 #if $fine_tune == "true" | |
| 31 --fine-tune | |
| 32 #end if | |
| 33 #end if | |
| 34 #if $customize_defaults == "true" | |
| 35 #if $epochs | |
| 36 --epochs "$epochs" | |
| 37 #end if | |
| 38 #if $early_stop | |
| 39 --early-stop "$early_stop" | |
| 40 #end if | |
| 41 #if $learning_rate_define == "true" | |
| 42 --learning-rate "$learning_rate" | |
| 43 #end if | |
| 44 #if $batch_size_define == "true" | |
| 45 --batch-size "$batch_size" | |
| 46 #end if | |
| 47 --split-probabilities "$train_split" "$val_split" "$test_split" | |
| 48 #end if | |
| 49 --random-seed "$random_seed" | |
| 50 --output-dir "." && | |
| 51 | |
| 52 mkdir -p '$output_model.extra_files_path' && | |
| 53 cp -r experiment_run/model/*.json experiment_run/model/model_weights '$output_model.extra_files_path' && | |
| 54 | |
| 55 echo "Image Learner Classification Experiment is Done!" | |
| 56 ]]> | |
| 57 </command> | |
| 58 | |
| 59 <inputs> | |
| 60 <param argument="input_csv" type="data" format="csv" optional="false" label="the metadata csv containing image_path column, label column and optional split column" /> | |
| 61 <param name="image_zip" type="data" format="zip" optional="false" label="Image zip" help="Image zip file containing your image data"/> | |
| 62 <param name="model_name" type="select" optional="false" label="Select a model for your experiment" > | |
| 63 | |
| 64 <option value="resnet18">Resnet18</option> | |
| 65 <option value="resnet34">Resnet34</option> | |
| 66 <option value="resnet50">Resnet50</option> | |
| 67 <option value="resnet101">Resnet101</option> | |
| 68 <option value="resnet152">Resnet152</option> | |
| 69 <option value="resnext50_32x4d">Resnext50_32x4d</option> | |
| 70 <option value="resnext101_32x8d">Resnext101_32x8d</option> | |
| 71 <option value="resnext101_64x4d">Resnext101_64x4d</option> | |
| 72 <option value="resnext152_32x8d">Resnext152_32x8d</option> | |
| 73 <option value="wide_resnet50_2">Wide_resnet50_2</option> | |
| 74 <option value="wide_resnet101_2">Wide_resnet101_2</option> | |
| 75 <option value="wide_resnet103_2">Wide_resnet103_2</option> | |
| 76 <option value="efficientnet_b0">Efficientnet_b0</option> | |
| 77 <option value="efficientnet_b1">Efficientnet_b1</option> | |
| 78 <option value="efficientnet_b2">Efficientnet_b2</option> | |
| 79 <option value="efficientnet_b3">Efficientnet_b3</option> | |
| 80 <option value="efficientnet_b4">Efficientnet_b4</option> | |
| 81 <option value="efficientnet_b5">Efficientnet_b5</option> | |
| 82 <option value="efficientnet_b6">Efficientnet_b6</option> | |
| 83 <option value="efficientnet_b7">Efficientnet_b7</option> | |
| 84 <option value="efficientnet_v2_s">Efficientnet_v2_s</option> | |
| 85 <option value="efficientnet_v2_m">Efficientnet_v2_m</option> | |
| 86 <option value="efficientnet_v2_l">Efficientnet_v2_l</option> | |
| 87 <option value="regnet_y_400mf">Regnet_y_400mf</option> | |
| 88 <option value="regnet_y_800mf">Regnet_y_800mf</option> | |
| 89 <option value="regnet_y_1_6gf">Regnet_y_1_6gf</option> | |
| 90 <option value="regnet_y_3_2gf">Regnet_y_3_2gf</option> | |
| 91 <option value="regnet_y_8gf">Regnet_y_8gf</option> | |
| 92 <option value="regnet_y_16gf">Regnet_y_16gf</option> | |
| 93 <option value="regnet_y_32gf">Regnet_y_32gf</option> | |
| 94 <option value="regnet_y_128gf">Regnet_y_128gf</option> | |
| 95 <option value="regnet_x_400mf">Regnet_x_400mf</option> | |
| 96 <option value="regnet_x_800mf">Regnet_x_800mf</option> | |
| 97 <option value="regnet_x_1_6gf">Regnet_x_1_6gf</option> | |
| 98 <option value="regnet_x_3_2gf">Regnet_x_3_2gf</option> | |
| 99 <option value="regnet_x_8gf">Regnet_x_8gf</option> | |
| 100 <option value="regnet_x_16gf">Regnet_x_16gf</option> | |
| 101 <option value="regnet_x_32gf">Regnet_x_32gf</option> | |
| 102 <option value="vgg11">Vgg11</option> | |
| 103 <option value="vgg11_bn">Vgg11_bn</option> | |
| 104 <option value="vgg13">Vgg13</option> | |
| 105 <option value="vgg13_bn">Vgg13_bn</option> | |
| 106 <option value="vgg16">Vgg16</option> | |
| 107 <option value="vgg16_bn">Vgg16_bn</option> | |
| 108 <option value="vgg19">Vgg19</option> | |
| 109 <option value="vgg19_bn">Vgg19_bn</option> | |
| 110 <option value="shufflenet_v2_x0_5">Shufflenet_v2_x0_5</option> | |
| 111 <option value="shufflenet_v2_x1_0">Shufflenet_v2_x1_0</option> | |
| 112 <option value="shufflenet_v2_x1_5">Shufflenet_v2_x1_5</option> | |
| 113 <option value="shufflenet_v2_x2_0">Shufflenet_v2_x2_0</option> | |
| 114 <option value="squeezenet1_0">Squeezenet1_0</option> | |
| 115 <option value="squeezenet1_1">Squeezenet1_1</option> | |
| 116 <option value="swin_t">Swin_t</option> | |
| 117 <option value="swin_s">Swin_s</option> | |
| 118 <option value="swin_b">Swin_b</option> | |
| 119 <option value="swin_v2_t">Swin_v2_t</option> | |
| 120 <option value="swin_v2_s">Swin_v2_s</option> | |
| 121 <option value="swin_v2_b">Swin_v2_b</option> | |
| 122 <option value="vit_b_16">Vit_b_16</option> | |
| 123 <option value="vit_b_32">Vit_b_32</option> | |
| 124 <option value="vit_l_16">Vit_l_16</option> | |
| 125 <option value="vit_l_32">Vit_l_32</option> | |
| 126 <option value="vit_h_14">Vit_h_14</option> | |
| 127 <option value="convnext_tiny">Convnext_tiny</option> | |
| 128 <option value="convnext_small">Convnext_small</option> | |
| 129 <option value="convnext_base">Convnext_base</option> | |
| 130 <option value="convnext_large">Convnext_large</option> | |
| 131 <option value="maxvit_t">Maxvit_t</option> | |
| 132 <option value="alexnet">Alexnet</option> | |
| 133 <option value="googlenet">Googlenet</option> | |
| 134 <option value="inception_v3">Inception_v3</option> | |
| 135 <option value="mobilenet_v2">Mobilenet_v2</option> | |
| 136 <option value="mobilenet_v3_large">Mobilenet_v3_large</option> | |
| 137 <option value="mobilenet_v3_small">Mobilenet_v3_small</option> | |
| 138 </param> | |
| 139 | |
| 140 <conditional name="scratch_fine_tune"> | |
| 141 <param name="use_pretrained" type="select" | |
| 142 label="Use pretrained weights?" | |
| 143 help="If select no, the encoder, combiner, and decoder will all be initialized and trained from scratch. | |
| 144 (e.g. when your images are very different from ImageNet or no suitable pretrained model exists.)"> | |
| 145 <option value="false">No</option> | |
| 146 <option value="true" selected="true">Yes</option> | |
| 147 </param> | |
| 148 <when value="true"> | |
| 149 <param name="fine_tune" type="select" label="Fine tune the encoder?" | |
| 150 help="Whether to fine tune the encoder(combiner and decoder will be fine-tued anyway)" > | |
| 151 <option value="false" >No</option> | |
| 152 <option value="true" selected="true">Yes</option> | |
| 153 </param> | |
| 154 </when> | |
| 155 <when value="false"> | |
| 156 <!-- No additional parameters to show if the user selects 'No' --> | |
| 157 </when> | |
| 158 </conditional> | |
| 159 <param argument="random_seed" type="integer" value="42" optional="true" label="Random seed (set for reproducibility)" min="0" max="999999"/> | |
| 160 <conditional name="advanced_settings"> | |
| 161 <param name="customize_defaults" type="select" label="Customize Default Settings?" help="Select yes if you want to customize the default settings of the experiment."> | |
| 162 <option value="false" selected="true">No</option> | |
| 163 <option value="true">Yes</option> | |
| 164 </param> | |
| 165 <when value="true"> | |
| 166 <param name="epochs" type="integer" value="10" min="1" max="99999" label="Epochs" help="Total number of full passes through the training dataset. Higher values may improve accuracy but increase training time. Default: 10." /> | |
| 167 <param name="early_stop" type="integer" value="5" min="1" max="99999" label="Early Stop" help="Number of epochs with no improvement after which training will be stopped. Default: 5." /> | |
| 168 <conditional name="learning_rate_condition"> | |
| 169 <param name="learning_rate_define" type="select" label="Define an initial learning rate?" help="Want to change the initial learning rate from default to a number? See ludwig.ai for more info. Default: No" > | |
| 170 <option value="false" selected="true" >No</option> | |
| 171 <option value="true">Yes</option> | |
| 172 </param> | |
| 173 <when value="true"> | |
| 174 <param name="learning_rate" type="float" value="0.001" min="0.0001" max="1.0" label="Learning Rate" help="Initial learning rate for the optimizer. Default: 0.001." /> | |
| 175 </when> | |
| 176 <when value="false"> | |
| 177 <!-- No additional parameters to show if the user selects 'No' --> | |
| 178 </when> | |
| 179 </conditional> | |
| 180 <conditional name="batch_size_condition"> | |
| 181 <param name="batch_size_define" type="select" label="Define your batch size?" help="Want to change the batch size from auto to a number? See ludwig.ai for more info. Default: No" > | |
| 182 <option value="false" selected="true" >No</option> | |
| 183 <option value="true">Yes</option> | |
| 184 </param> | |
| 185 <when value="true"> | |
| 186 <param name="batch_size" type="integer" value="32" min="1" max="99999" label="Batch Size" help="Number of samples per gradient update. Default: 32." /> | |
| 187 </when> | |
| 188 <when value="false"> | |
| 189 <!-- No additional parameters to show if the user selects 'No' --> | |
| 190 </when> | |
| 191 </conditional> | |
| 192 <param name="train_split" type="float" | |
| 193 label="Training split proportion (only works if no split column in the metadata csv)" | |
| 194 value="0.7" | |
| 195 help="Fraction of data for training (e.g., 0.7). train split + val split + test split should = 1"/> | |
| 196 <param name="val_split" type="float" | |
| 197 label="Validation split proportion (only works if no split column in the metadata csv)" | |
| 198 value="0.1" | |
| 199 help="Fraction of data for validation (e.g., 0.1). train split + val split + test split should = 1"/> | |
| 200 <param name="test_split" type="float" | |
| 201 label="Test split proportion (only works if no split column in the metadata csv)" | |
| 202 value="0.2" | |
| 203 help="Fraction of data for testing (e.g., 0.2) train split + val split + test split should = 1."/> | |
| 204 </when> | |
| 205 <when value="false"> | |
| 206 <!-- No additional parameters to show if the user selects 'No' --> | |
| 207 </when> | |
| 208 </conditional> | |
| 209 </inputs> | |
| 210 <outputs> | |
| 211 <data format="ludwig_model" name="output_model" label="${tool.name} trained model on ${on_string}" /> | |
| 212 <data format="html" name="output_report" from_work_dir="image_classification_results_report.html" label="${tool.name} report on ${on_string}" /> | |
| 213 <collection type="list" name="output_pred_csv" label="${tool.name} predictions CSVs/experiment stats/plots on ${on_string}" > | |
| 214 <discover_datasets pattern="(?P<designation>predictions\.csv)" format="csv" directory="experiment_run" /> | |
| 215 <discover_datasets pattern="(?P<designation>.+)\.json" format="json" directory="experiment_run" /> | |
| 216 <discover_datasets pattern="(?P<designation>.+)\.png" format="png" directory="experiment_run/visualizations/train" /> | |
| 217 <discover_datasets pattern="(?P<designation>.+)\.png" format="png" directory="experiment_run/visualizations/test" /> | |
| 218 </collection> | |
| 219 </outputs> | |
| 220 <tests> | |
| 221 <test expect_num_outputs="3"> | |
| 222 <param name="input_csv" value="mnist_subset.csv" ftype="csv" /> | |
| 223 <param name="image_zip" value="mnist_subset.zip" ftype="zip" /> | |
| 224 <param name="model_name" value="resnet18" /> | |
| 225 <output name="output_report" file="image_classification_results_report_mnist.html" compare="sim_size" delta="20000" > | |
| 226 <assert_contents> | |
| 227 <has_text text="Epochs" /> | |
| 228 </assert_contents> | |
| 229 </output> | |
| 230 | |
| 231 <output_collection name="output_pred_csv" type="list" > | |
| 232 <element name="predictions.csv" > | |
| 233 <assert_contents> | |
| 234 <has_n_columns n="1" /> | |
| 235 </assert_contents> | |
| 236 </element> | |
| 237 </output_collection> | |
| 238 </test> | |
| 239 </tests> | |
| 240 <help> | |
| 241 <![CDATA[ | |
| 242 **What it does** | |
| 243 Image Learner for Classification: trains and evaluates a image classification model. | |
| 244 It uses the metadata csv to find the image paths and labels. | |
| 245 The metadata csv should contain a column with the name 'image_path' and a column with the name 'label'. | |
| 246 Optionally, you can also add a column with the name 'split' to specify which split each row belongs to (train, val, test). | |
| 247 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. | |
| 248 | |
| 249 | |
| 250 **Outputs** | |
| 251 The tool will output a trained model in the form of a ludwig_model file, | |
| 252 a report in the form of an HTML file, and a collection of CSV/json/png files containing the predictions, experiment stats and visualizations. | |
| 253 The html report will contain metrics&experiment setup parameters, train&val plots and test plots. | |
| 254 | |
| 255 ]]> | |
| 256 </help> | |
| 257 <citations> | |
| 258 <citation type="bibtex"> | |
| 259 @misc{https://doi.org/10.48550/arxiv.1909.07930, | |
| 260 doi = {10.48550/ARXIV.1909.07930}, | |
| 261 url = {https://arxiv.org/abs/1909.07930}, | |
| 262 author = {Molino, Piero and Dudin, Yaroslav and Miryala, Sai Sumanth}, | |
| 263 title = {Ludwig: a type-based declarative deep learning toolbox}, | |
| 264 publisher = {arXiv}, | |
| 265 year = {2019}, | |
| 266 copyright = {arXiv.org perpetual, non-exclusive license} | |
| 267 } | |
| 268 </citation> | |
| 269 </citations> | |
| 270 </tool> |
