Custom Environment & Custom Model

#1
by cm107 - opened

My question is: How did you set up this space and get it working?

I have my own custom scene in unity where I trained my own custom agent.
I built the game using WebGL (with development build checked), and that gives me the following:

├── Build
│   ├── test-webgl-dev.data
│   ├── test-webgl-dev.framework.js
│   ├── test-webgl-dev.loader.js
│   └── test-webgl-dev.wasm
├── index.html
├── StreamingAssets
│   └── UnityServicesProjectConfiguration.json
└── TemplateData
    ├── favicon.ico
    ├── fullscreen-button.png
    ├── progress-bar-empty-dark.png
    ├── progress-bar-empty-light.png
    ├── progress-bar-full-dark.png
    ├── progress-bar-full-light.png
    ├── style.css
    ├── unity-logo-dark.png
    ├── unity-logo-light.png
    └── webgl-logo.png

Using this repository as a reference, I copied index.html, Build, and TemplateData into my space's repository folder.

This is what happens when I run index.html in Chrome.

I think that I need to change my build settings somehow in order to avoid this error.
What were your build settings when you created your WebGL build?

Furthermore, I also tried cloning this repository and running it locally on my computer to see what would happen.

I get stuck at the loading screen.

I'm guessing that the model itself is linked to your repository somehow through huggingspace, which means simply cloning your repository by itself isn't enough to run your game locally.
How specifically are your agent weights linked to your repository?
I would like to do the same in mine, but I'm not exactly sure how you did it.
I'm guessing that you probably used a variation of this script, but huggingface/ml-agents doesn't explain how to link a custom model to your own space.

Would you be so kind as to point me in the right direction? I would greatly appreciate it!

I found one of your posts in the unity forms.
It looks like you are downloading the model directly from within your unity environment here.
Are you still doing this in your final implementation?
If possible, it would be nice if you could show the source code.

I figured it out.
I just needed to use your
Unity-WebGL-template-for-Hugging-Face-Spaces
.
For anyone else that is trying to do the same thing as me:

  1. Clone
    Unity-WebGL-template-for-Hugging-Face-Spaces
    .
  2. In your Unity Editor, drag 'Hugging Face WebGL Template.unitypackage' into your Assets folder any import everything.
  3. Open your player settings (Edit> Project Settings > Player), and under the WebGL tab, under Resolution and Presentation, select the "Hugging Face" template.
  4. Open your Build Settings, change your platform to WebGL, check Development Build (this might be optional), and then click Build And Run.
  5. If the build went well, your game should open up in your default browser with your agents using the weights that you referenced inside of your scene.
  6. Create a new huggingface space using the Static SDK.
  7. Clone your new space to your computer.
  8. cp -r /path/to/build/directory/* /path/to/space/repo/
  9. Since the *.data files in your Build folder are likely too big, you will need to track them with git lfs. git lfs install && git lfs track "*.data"
  10. Commit and push. You might be asked to enter your username and password multiple times for each file that needs to be tracked with lfs.
  11. Go to your space on huggingface and confirm that the app is working.

Sign up or log in to comment