diff --git a/ENV_CONFIG.md b/ENV_CONFIG.md new file mode 100644 index 00000000..1f585f67 --- /dev/null +++ b/ENV_CONFIG.md @@ -0,0 +1,24 @@ +# 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 +# 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..8d21cac9 100644 --- a/app.py +++ b/app.py @@ -400,4 +400,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..2428c8bb 100644 --- a/app_text.py +++ b/app_text.py @@ -263,4 +263,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' + )