Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Last active June 12, 2016 02:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cgcardona/69015852f193d7f879996863c87b6769 to your computer and use it in GitHub Desktop.
Save cgcardona/69015852f193d7f879996863c87b6769 to your computer and use it in GitHub Desktop.

Introduction to Magenta

We’re happy to announce Magenta, a project from the Google Brain team that asks: Can we use machine learning to create compelling art and music? If so, how? If not, why not?

Steps to setup Magenta

Clone the repo

git clone git@github.com:tensorflow/magenta.git --recursive
cd magenta

The --recursive flag automatically initializes and updates each submodule in the repository. More info on git submodules

Configure tensorflow

I just went w/ the default options.

cd tensorflow
./configure
cd ..

Build the project(s)

These are found in magenta/BUILD.

bazel build //magenta:music_py_pb3
# Generates bazel-genfiles/magenta/protobuf/music_pb2.py

bazel build //magenta:music_proto
# Generates
#  * bazel-bin/magenta/*
#  * bazel-genfiles/magenta/protobuf/music.pb.cc
#  * bazel-genfiles/magenta/protobuf/music.pb.h

bazel build //magenta:midi_io_test
bazel build //magenta:midi_io

music_pb2.py

music_pb2.py is a python protocol buffer which was compiled from magenta/protobuf/music.proto.

// A message containing a symbolic music sequence. The design is largely based on MIDI but it should be able to represent any music sequence.

As such I don't think we run it directly from the command line. Instead I believe that we import it and use it as an interface in our code.

magenta/lib

I think that this is the sample code which we are supposed to run. However when I run python magenta/lib/midi_io_test.py I get

Traceback (most recent call last):
  File "magenta/lib/midi_io_test.py", line 8, in <module>
    import google3
ImportError: No module named google3

I'm unable to install google3 via pip:

$ pip install google3                                                                                                     
Collecting google3
  Could not find a version that satisfies the requirement google3 (from versions: )
No matching distribution found for google3

I've googled around and I don't see a python package called google3 so I'm still trying to debug this.

Also when I run

$ python magenta/lib/midi_io.py                                                                                             
Traceback (most recent call last):
  File "magenta/lib/midi_io.py", line 10, in <module>
    import pretty_midi
ImportError: No module named pretty_midi

There is a pretty_midi package in the third_party directory which is used in the compilation step above so I'm unclear what's happening here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment