Memory buffered file

toàn
toàn New Altair Community Member
edited November 5 in Community Q&A

I want to convert matrix shape 28x28 to 1x784, i use execute python to do it, this code below here but result moniter Memory buffered file. Can you fix this problem, thanks !

Tagged:

Best Answer

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    And by the way, there is no need for python if you use the Image Processing extension.

Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hey,
    basically everything that is not a pd.DataFrame is pickled and you get the pickled version. This is then the purple fileobject, which you cannot use with any operator in RM, other than another Exec Python operator.

    -> You want to return a pd.DataFrame here.

    Best,
    Martin
  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    And by the way, there is no need for python if you use the Image Processing extension.
  • toàn
    toàn New Altair Community Member
    hey martin, you think i should use another operator in image proccess to convert? 
  • toàn
    toàn New Altair Community Member

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi @tóan,
    yes. I would do it like this:



    This is the process:
    <?xml version="1.0" encoding="UTF-8"?><process version="10.3.000">
    
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="10.3.000" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
    <operator activated="true" class="image_processing:read_image" compatibility="0.3.002" expanded="true" height="68" name="Read Image" width="90" x="179" y="34">
    <parameter key="file" value="C:/Users/MartinSchmitz/Downloads/Capture.PNG"/>
    <parameter key="show_pdf_options" value="false"/>
    <parameter key="dpi" value="300"/>
    <parameter key="read_all_pages" value="false"/>
    <parameter key="enforce_pdf" value="false"/>
    <description align="center" color="transparent" colored="false" width="126">Change the path here</description>
    </operator>
    <operator activated="true" class="image_processing:color_convert" compatibility="0.3.002" expanded="true" height="82" name="Convert Color" width="90" x="313" y="34">
    <description align="center" color="transparent" colored="false" width="126">Turns it into B/W</description>
    </operator>
    <operator activated="true" class="image_processing:resize_image" compatibility="0.3.002" expanded="true" height="82" name="Resize Image" width="90" x="447" y="34">
    <parameter key="width" value="100"/>
    <parameter key="height" value="100"/>
    <description align="center" color="transparent" colored="false" width="126">for speed reasons just 100x100</description>
    </operator>
    <operator activated="true" class="image_processing:img_to_table" compatibility="0.3.002" expanded="true" height="82" name="Image to Table" width="90" x="581" y="34"/>
    <operator activated="true" class="blending:generate_id" compatibility="10.3.000" expanded="true" height="82" name="Generate ID" width="90" x="715" y="34">
    <parameter key="create_nominal_ids" value="false"/>
    <parameter key="offset" value="1"/>
    </operator>
    <operator activated="true" class="blending:pivot" compatibility="10.3.000" expanded="true" height="103" name="Pivot" width="90" x="849" y="34">
    <parameter key="group_by_attributes" value=""/>
    <parameter key="column_grouping_attribute" value="id"/>
    <list key="aggregation_attributes"/>
    <parameter key="use_default_aggregation" value="true"/>
    <parameter key="default_aggregation_function" value="first"/>
    </operator>
    <operator activated="true" class="rename_by_replacing" compatibility="10.3.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="983" y="34">
    <parameter key="attribute_filter_type" value="all"/>
    <parameter key="attribute" value=""/>
    <parameter key="attributes" value=""/>
    <parameter key="use_except_expression" value="false"/>
    <parameter key="value_type" value="attribute_value"/>
    <parameter key="use_value_type_exception" value="false"/>
    <parameter key="except_value_type" value="time"/>
    <parameter key="block_type" value="attribute_block"/>
    <parameter key="use_block_type_exception" value="false"/>
    <parameter key="except_block_type" value="value_matrix_row_start"/>
    <parameter key="invert_selection" value="false"/>
    <parameter key="include_special_attributes" value="false"/>
    <parameter key="replace_what" value="first\(Column(\d+)\)_(\d+)"/>
    <parameter key="replace_by" value="$1_$2"/>
    </operator>
    <connect from_op="Read Image" from_port="img" to_op="Convert Color" to_port="image input"/>
    <connect from_op="Convert Color" from_port="image output" to_op="Resize Image" to_port="image input"/>
    <connect from_op="Resize Image" from_port="image output" to_op="Image to Table" to_port="img"/>
    <connect from_op="Image to Table" from_port="exa" to_op="Generate ID" to_port="example set input"/>
    <connect from_op="Generate ID" from_port="example set output" to_op="Pivot" to_port="input"/>
    <connect from_op="Pivot" from_port="output" to_op="Rename by Replacing" to_port="example set input"/>
    <connect from_op="Rename by Replacing" from_port="example set output" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>



    BR,
    Martin


  • toàn
    toàn New Altair Community Member
    edited November 2023
    thank you