From 1fc6f1f9e378f45892331f5180bb186d6bea6d00 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 16:21:45 -0700 Subject: [PATCH 1/3] Add sane defaults for ENV --- ENV_CONFIG.md | 27 +++++++++++++++++++++++++++ app.py | 8 +++++++- app_text.py | 8 +++++++- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 ENV_CONFIG.md diff --git a/ENV_CONFIG.md b/ENV_CONFIG.md new file mode 100644 index 00000000..ed0835e5 --- /dev/null +++ b/ENV_CONFIG.md @@ -0,0 +1,27 @@ +# TRELLIS Environment Variable Configuration + +## Overview + +The TRELLIS apps now support environment variable configuration for Gradio server settings. + +## Environment Variables + +### Gradio Server Configuration +These are handled directly in `app.py` and `app_text.py`: + +- `GRADIO_SERVER_NAME` (default: `0.0.0.0`) - Server binding address +- `GRADIO_SERVER_PORT` (default: `7860`) - Server port +- `GRADIO_SHARE` (default: `false`) - Enable public sharing + +## Usage + +```bash +# Basic usage with defaults +python3 app.py + +# Custom configuration +export GRADIO_SERVER_NAME=0.0.0.0 +export GRADIO_SERVER_PORT=8080 +export GRADIO_SHARE=true +python3 app.py +``` diff --git a/app.py b/app.py index bd859467..07558ed2 100644 --- a/app.py +++ b/app.py @@ -14,6 +14,8 @@ from trellis.utils import render_utils, postprocessing_utils + + MAX_SEED = np.iinfo(np.int32).max TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp') os.makedirs(TMP_DIR, exist_ok=True) @@ -400,4 +402,8 @@ def split_image(image: Image.Image) -> List[Image.Image]: if __name__ == "__main__": pipeline = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large") pipeline.cuda() - demo.launch() + demo.launch( + server_name=os.environ.get('GRADIO_SERVER_NAME', '0.0.0.0'), + server_port=int(os.environ.get('GRADIO_SERVER_PORT', '7860')), + share=os.environ.get('GRADIO_SHARE', 'false').lower() == 'true' + ) diff --git a/app_text.py b/app_text.py index 56b414bd..a8e3e9c5 100644 --- a/app_text.py +++ b/app_text.py @@ -13,6 +13,8 @@ from trellis.utils import render_utils, postprocessing_utils + + MAX_SEED = np.iinfo(np.int32).max TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp') os.makedirs(TMP_DIR, exist_ok=True) @@ -263,4 +265,8 @@ def extract_gaussian(state: dict, req: gr.Request) -> Tuple[str, str]: if __name__ == "__main__": pipeline = TrellisTextTo3DPipeline.from_pretrained("microsoft/TRELLIS-text-xlarge") pipeline.cuda() - demo.launch() + demo.launch( + server_name=os.environ.get('GRADIO_SERVER_NAME', '0.0.0.0'), + server_port=int(os.environ.get('GRADIO_SERVER_PORT', '7860')), + share=os.environ.get('GRADIO_SHARE', 'false').lower() == 'true' + ) From b84d57db258abbc06a6d09f791c13d799449eb7c Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 17:21:03 -0700 Subject: [PATCH 2/3] update for formatting and docs --- ENV_CONFIG.md | 3 --- app.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/ENV_CONFIG.md b/ENV_CONFIG.md index ed0835e5..1f585f67 100644 --- a/ENV_CONFIG.md +++ b/ENV_CONFIG.md @@ -16,9 +16,6 @@ These are handled directly in `app.py` and `app_text.py`: ## Usage ```bash -# Basic usage with defaults -python3 app.py - # Custom configuration export GRADIO_SERVER_NAME=0.0.0.0 export GRADIO_SERVER_PORT=8080 diff --git a/app.py b/app.py index 07558ed2..8d21cac9 100644 --- a/app.py +++ b/app.py @@ -14,8 +14,6 @@ from trellis.utils import render_utils, postprocessing_utils - - MAX_SEED = np.iinfo(np.int32).max TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp') os.makedirs(TMP_DIR, exist_ok=True) From d43582f51d0acfdc2c73bdc46303f18c3f4c67c4 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 17:21:36 -0700 Subject: [PATCH 3/3] remove whitespace --- app_text.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app_text.py b/app_text.py index a8e3e9c5..2428c8bb 100644 --- a/app_text.py +++ b/app_text.py @@ -13,8 +13,6 @@ from trellis.utils import render_utils, postprocessing_utils - - MAX_SEED = np.iinfo(np.int32).max TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp') os.makedirs(TMP_DIR, exist_ok=True)