googlecreativelab / aiexperiments-ai-duet

A piano that responds to you.
https://aiexperiments.withgoogle.com/ai-duet
1.63k stars 283 forks source link

2 errors: `ERROR in app: Exception on /predict [POST]` and `TypeError: generate() takes exactly 3 arguments (2 given)` #2

Closed gnestor closed 7 years ago

gnestor commented 7 years ago

I followed the install instructions except that that pip failed on magenta:

Collecting magenta==0.1.3 (from -r requirements.txt (line 15))
  Could not find a version that satisfies the requirement magenta==0.1.3 (from -r requirements.txt (line 15)) (from versions: )
No matching distribution found for magenta==0.1.3 (from -r requirements.txt (line 15))

So I followed the magenta install instructions and then activated the conda environment source activate magenta and then pip install -r requirements.txt and python server.py.

[2016-11-15 16:00:08,627] ERROR in app: Exception on /predict [POST]
Traceback (most recent call last):
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 39, in predict
    ret_midi = generate_midi(midi_data, duration)
  File "/Users/grant/Downloads/aiexperiments-ai-duet-master/server/predict.py", line 52, in generate_midi
    generate_response = basic_generator.generate(generate_request)
TypeError: generate() takes exactly 3 arguments (2 given)
127.0.0.1 - - [15/Nov/2016 16:00:08] "POST /predict?duration=1.986848072562358&generator=pop HTTP/1.1" 500 -
[2016-11-15 16:00:18,052] ERROR in app: Exception on /predict [POST]
Traceback (most recent call last):
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/grant/anaconda/envs/magenta/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 39, in predict
    ret_midi = generate_midi(midi_data, duration)
  File "/Users/grant/Downloads/aiexperiments-ai-duet-master/server/predict.py", line 52, in generate_midi
    generate_response = basic_generator.generate(generate_request)
davkap92 commented 7 years ago

Hey very cool project thanks, experiencing same issue when running. Thanks

orangesandcream commented 7 years ago

Also experiencing this issue

ItsThisGuyAgain commented 7 years ago

Same here

hyperobject commented 7 years ago

+1

almostimplemented commented 7 years ago

I also encountered this problem. A workaround:

In predict.py starting at line 52:

-    generate_response = basic_generator.generate(generate_request)
+    generate_response = basic_generator.generate(generate_request.input_sequence, generate_request.generator_options)
     output = tempfile.NamedTemporaryFile()
     midi_io.sequence_proto_to_midi_file(
-          generate_response.generated_sequence, output.name)
+          generate_response, output.name)

This worked for me and now I'm trading fourths with a neural net. 👍

almostimplemented commented 7 years ago

As I began playing around further, I hit similar bugs.

I believe the problems stem from the commit: https://github.com/googlecreativelab/aiexperiments-ai-duet/commit/22b52a3f18e27af92ae64da46a8ad8bad4a08c73 to move the local magenta module beneath third_party. There is logic in predict.py and the local magenta that expects the to access those local files.

I was able to fix this issue and another issue I encountered by moving the magenta directory to be level with server.py.

davkap92 commented 7 years ago

@almostimplemented Great Thanks the moving of magenta up a level got it working, 👍

gnestor commented 7 years ago

https://github.com/googlecreativelab/aiexperiments-ai-duet/pull/1 resolves this for me!

Hdooster commented 7 years ago

@almostimplemented thanks, this works.

tambien commented 7 years ago

Sorry did catch that issue that i created by moving Magenta into the third_party folder. We were just trying to make sure that Magenta was properly credited as a third_party project and not part of this project, but it introduced that issue.

I appended the third_party folder to the system path which fixes the issue on my end. Please reopen if that doesn't solve it.

almostimplemented commented 7 years ago

LGTM; thanks @tambien ! And bigger thanks in general for the code!