view json2yolosegment.xml @ 4:f6990d85161c draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit c6c9d43a4ecdc88ebdeaf3451453a550f159c506
author bgruening
date Mon, 21 Jul 2025 15:51:13 +0000
parents dfda27273ead
children
line wrap: on
line source

<tool id="json2yolosegment" name="Convert AnyLabeling JSON to YOLO text" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="24.2">
    <description>with ultralytics</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="creator" />
    <expand macro="edam" />
    <expand macro="requirements" />
    <command detect_errors="aggressive">
    <![CDATA[
    mkdir ./input ./output &&

    #for $filename in $in_json:
        #if $filename.element_identifier.endswith($filename.ext)
            ln -s '$filename' './input/${filename.element_identifier}' &&
        #else:
            ln -s '$filename' './input/${filename.element_identifier}.${filename.ext}' &&
        #end if
    #end for

    python '$__tool_directory__/json2yolosegment.py'
	-i ./input/
	-o ./output
	-c '$class_name'
	
    ]]>
    </command>
    <inputs>
        <param name="in_json" type="data" format="json" multiple="true" label="Input label files" help="The label file is the output of AnyLabeling in JSON format."/>
        <param name="class_name" type="data" format="txt" label="Class file" help="Class names text file, contains the names of classes, one class per row."/>
    </inputs>
    <outputs>
        <collection name="output_yolo" type="list" label="YOLO text files">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.txt" directory="./output" format="txt"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="in_json" value="in_json.json,in_json1.json" />
            <param name="class_name" value="class_names.txt" />
            <output_collection name="output_yolo">
                <element name="in_json">
                    <assert_contents>
                        <has_n_lines n="1" />
                        <has_text text="0.8532289628180039" />
                    </assert_contents>
                </element>
                <element name="in_json1">
                    <assert_contents>
                        <has_n_lines n="1" />
                        <has_text text="0.7710371819960861" />
                    </assert_contents>
                </element>
            </output_collection>
        </test>
        <test>
            <param name="in_json" value="in_json_noext,in_json1_noext" />
            <param name="class_name" value="class_names.txt" />
            <output_collection name="output_yolo">
                <element name="in_json1_noext">
                    <assert_contents>
                        <has_n_lines n="1" />
                        <has_text text="0.7710371819960861" />
                    </assert_contents>
                </element>
                <element name="in_json_noext">
                    <assert_contents>
                        <has_n_lines n="1" />
                        <has_text text="0.8532289628180039" />
                    </assert_contents>
                </element>
            </output_collection>
        </test>
    </tests>
    <help>
<![CDATA[
        **What it does**
        This tool converts label files generated by AnyLabeling into YOLO supported text files.
]]>
    </help>
    <expand macro="citations" />
</tool>