Spaces:
Running
on
A100
title: LegoGPT-Demo
emoji: 🧱
short_description: Generate stable LEGO structures from text prompts.
app_file: app.py
sdk: gradio
sdk_version: 5.29.0
python_version: 3.11
models:
- AvaLovelace/LegoGPT
LegoGPT Demo
Gradio demo for LegoGPT.
Prerequisites
Llama-3.2-1B-Instruct: LegoGPT is fine-tuned from meta-llama/Llama-3.2-1B-Instruct, a gated model. Request access to the model here, then generate a Hugging Face user access token.
- If running locally, set your access token as an environment variable:
export HF_TOKEN=<your_token>
- If running on Hugging Face Spaces, set your access token as the
HF_TOKEN
secret in the Settings tab of your Space.
The model will be automatically downloaded upon running the code.
- If running locally, set your access token as an environment variable:
Gurobi: Running stability analysis requires a Gurobi licence to use Gurobi. Academics may request a free licence from the Gurobi website here.
- If running locally, place the Gurobi licence file in your home directory or another recommended location.
- If running on Hugging Face Spaces, the licence type must be Web License Service (WLS). Set the
WLSACCESSID
,WLSSECRET
, andLICENSEID
secrets in the Settings tab of your Space to their values in your Gurobi licence file.
ImportLDraw: Rendering LEGO visualizations requires ImportLDraw, provided as a Git submodule.
- If running locally, follow these instructions to install ImportLDraw:
- Download Git LFS, then run
git lfs install
. - Install Git submodules with
git submodule update --init
. - Download the LDraw parts library and
extract it in your home directory:
(cd ~ && wget https://library.ldraw.org/library/updates/complete.zip && unzip complete.zip)
.- If you wish to put the LDraw parts library in a different directory, set the environment variable
LDRAW_LIBRARY_PATH
to the path of theldraw
directory:export LDRAW_LIBRARY_PATH=path/to/ldraw
.
- If you wish to put the LDraw parts library in a different directory, set the environment variable
- Download Git LFS, then run
- If running on Hugging Face Spaces, ImportLDraw and the LDraw parts library will automatically be downloaded and
installed by the
app.py
script.
- If running locally, follow these instructions to install ImportLDraw:
Running locally
Install the Python project manager uv. Then run the demo with:
uv run app.py
Running on Hugging Face Spaces
Make sure the origin of this repo is set to your Space:
git remote set-url origin git@hf.co:spaces/<your_username>/<your_space_name>
Then commit and push your changes to your Space with
git add -A && git commit -m "Update" && git push
If you've changed the dependencies in
pyproject.toml
, update therequirements.txt
file accordingly:uv export --format requirements-txt --no-hashes > requirements.txt
Then,
git commit
andgit push
the changes to your Space. You may have to restart the Space for the changes to take effect.