Project

treyja

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Treyja: parses and displays tensors.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
>= 0
~> 10.0
~> 3.0

Runtime

 Project Readme

Treyja

Treyja is a Ruby script which takes Tensors protobin and outputs in human readable way.

Installation

Make sure you have ruby and gem commands installed.

$ ruby --version
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17]
$ gem --version
2.7.6

Install it yourself as:

$ gem install treyja

How to use

Assume that we are in the root dir of alderaan.

To show in JSON format

$ draupnir stream draupnir/test/fixtures/configuration/literal.yaml | treyja json
{"tensors":[{"dims":[3,2],"dataType":"FLOAT","int32Data":[],"int64Data":[],"uint32Data":[],"uint64Data":[],"floatData":[0.2,0.30000001,1,2,3,5],"doubleData":[]}]}
{"tensors":[{"dims":[3,2],"dataType":"FLOAT","int32Data":[],"int64Data":[],"uint32Data":[],"uint64Data":[],"floatData":[0,0,0.5,0.60000002,0.69999999,0.80000001],"doubleData":[]}]}

Using jq (optional)

jq command is handy to pretty print JSON.

$ draupnir stream draupnir/test/fixtures/configuration/literal.yaml | treyja json | jq
{
  "tensors": [
    {
      "dims": [
        3,
        2
      ],
      "dataType": "FLOAT",
      "int32Data": [],
      "int64Data": [],
      "uint32Data": [],
      "uint64Data": [],
      "floatData": [
        0.2,
        0.30000001,
        1,
        2,
        3,
        5
      ],
      "doubleData": []
    }
  ]
}
{
  "tensors": [
    {
      "dims": [
        3,
        2
      ],
      "dataType": "FLOAT",
      "int32Data": [],
      "int64Data": [],
      "uint32Data": [],
      "uint64Data": [],
      "floatData": [
        0,
        0,
        0.5,
        0.60000002,
        0.69999999,
        0.80000001
      ],
      "doubleData": []
    }
  ]
}

To output png image

Output png image files into the directory specified by --output option.

Shape of input tensors must be 3 dimensional and channel count must be 1 (grayscale), 2 (grayscale and alpha), 3 (RGB) or 4 (RGB and alpha).

Element type of input tensors must be uint8, int8, float or double.

$ draupnir stream mnist --take 100 | treyja image --output tmp/mnist-images

mnist-0 mnist-1 mnist-2 mnist-3

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Setup Ruby

If rake or bundle failed, you may not have ruby installed on your system.

Setup ruby in your favorite way.

With nix-env, you can install ruby-2.5.x by:

$ nix-env -i $(nix-env -qa | grep ruby-2.5)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xc-jp/treyja-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Treyja project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.