shyamsn97/mario-gpt

And now what?

fares57 opened this issue · 17 comments

Ok I sense this will be a very stupid question.

so we generate AI Mario levels. perfect! How do we play them? :p

Hey great timing haha. I've just updated the main branch README with instructions. Gonna update the pip package as well :)

now you can do:

from mario_gpt import MarioLM, SampleOutput
mario_lm = MarioLM()

# use cuda to speed stuff up
# import torch
# device = torch.device('cuda')
# mario_lm = mario_lm.to(device)

prompts = ["many pipes, many enemies, some blocks, high elevation"]

# generate level of size 1400, pump temperature up to ~2.4 for more stochastic but playable levels
generated_level = mario_lm.sample(
    prompts=prompts,
    num_steps=1400,
    temperature=2.0,
    use_tqdm=True
)

# play in interactive
generated_level.play()

Also, you can check out the lovely demo on huggingface: https://huggingface.co/spaces/multimodalart/mariogpt

VScode
(after 35' of waiting)
warnings.warn(
Using shyamsn97/Mario-GPT2-700-context-length tokenizer
shape: torch.Size([1, 672]), torch.Size([1, 1401]) first: 56, last: 56: 100%|███████████| 1400/1400 [35:25<00:00, 1.52s/it]
Traceback (most recent call last):
File "c:/Users/ikout/Documents/DEVELOPMENT/pythonjams/mariogpt.py", line 15, in
generated_level.play()
AttributeError: 'Tensor' object has no attribute 'play'

the colab that a fan made is not working either.

huggingface works only with the examples . it gives error when I try to generate mine

Seems like you’re using an older version? Try uninstalling and installing it from the GitHub repo again

And yeah the huggingface demo needs to be updated with the newer version of the code.

Seems like you’re using an older version? Try uninstalling and installing it from the GitHub repo again

Cloning into 'mario-gpt'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Looks like you probably have to configure git: https://docs.github.com/en/get-started/quickstart/set-up-git

asi-9 commented

Facing this error -> RuntimeError: shape '[-1, 14]' is invalid for input of size 701.

image

Looks like you may be running an older version so the examples have changed slightly:

Can you run this in python?

from importlib.metadata import version
print(version('mario-gpt'))

it should print '0.1.2'

asi-9 commented

its 0.1.1, how do I install the newer version. I just downloaded then why was 0.1.1 installed ?
image

Yeah looks like it says 0.1.1, so you should re install it either with:

pip install mario-gpt --upgrade

or by cloning the repo

git clone git@github.com:shyamsn97/mario-gpt.git
python setup.py install
asi-9 commented

I can't get it to run :(
image

Actually it is working 🙂! Now you don’t have to use the view_level method. You can do generated_level.level to view the strings, generated_level.img to view the image, and generated_level.play() to actually play the level

Full example from README

from mario_gpt import MarioLM, SampleOutput

# pretrained_model = shyamsn97/Mario-GPT2-700-context-length

mario_lm = MarioLM()

# use cuda to speed stuff up
# import torch
# device = torch.device('cuda')
# mario_lm = mario_lm.to(device)

prompts = ["many pipes, many enemies, some blocks, high elevation"]

# generate level of size 1400, pump temperature up to ~2.4 for more stochastic but playable levels
generated_level = mario_lm.sample(
    prompts=prompts,
    num_steps=1400,
    temperature=2.0,
    use_tqdm=True
)

# show string list
generated_level.level

# show PIL image
generated_level.img

# save image
generated_level.img.save("generated_level.png")

# save text level to file
generated_level.save("generated_level.txt")

# play in interactive
generated_level.play()

# run Astar agent
generated_level.run_astar()

# load from text file
loaded_level = SampleOutput.load("generated_level.txt")

# play from loaded (should be the same level that we generated)
loaded_level.play()
...
asi-9 commented

Worked, thank you!

Awesome!

Closing this as we added ways to play / run an astar agent on a level.