From ad00a782edd34c7c2eae5f4b576e9fa1a3e53d46 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 16:30:22 -0700 Subject: [PATCH 1/3] Example --- services/trellis/app_wrapper.py | 35 +++++++++++---------------------- services/trellis/source | 2 +- services/trellis/startup.sh | 8 ++------ 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/services/trellis/app_wrapper.py b/services/trellis/app_wrapper.py index 1552358..5aecbe6 100644 --- a/services/trellis/app_wrapper.py +++ b/services/trellis/app_wrapper.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Simple wrapper for TRELLIS app that fixes both localhost binding and Gradio JSON schema issues. +Simple wrapper for TRELLIS app that fixes Gradio JSON schema issues. """ import os @@ -8,9 +8,9 @@ import traceback def patch_gradio_issues(): - """Patch both the localhost binding and JSON schema issues""" + """Patch the Gradio JSON schema bug""" - # Patch 1: Fix JSON schema bug + # Patch: Fix JSON schema bug try: import gradio_client.utils as client_utils @@ -41,39 +41,28 @@ def patched_get_type(schema, defs=None): except Exception as e: print(f"⚠️ Could not patch Gradio schema bug: {e}") - - # Patch 2: Fix localhost binding by setting environment variables - os.environ.setdefault('GRADIO_SERVER_NAME', '0.0.0.0') - os.environ.setdefault('GRADIO_SERVER_PORT', '7860') - print(f"✅ Set server binding to {os.environ['GRADIO_SERVER_NAME']}:{os.environ['GRADIO_SERVER_PORT']}") def main(): """Main function that patches issues and launches TRELLIS""" - print("🚀 Starting TRELLIS with fixes applied...") + print("🚀 Starting TRELLIS with Gradio patch applied...") # Apply patches patch_gradio_issues() - # Add current directory to Python path - sys.path.insert(0, os.getcwd()) + # Add source directory to Python path + source_dir = os.path.join(os.path.dirname(__file__), 'source') + sys.path.insert(0, source_dir) try: - # Import and launch TRELLIS + # Change to source directory and import app + os.chdir(source_dir) import app print("✅ TRELLIS app imported successfully") - if hasattr(app, 'demo'): - print("🎯 Launching TRELLIS Gradio interface...") - app.demo.launch( - server_name=os.environ['GRADIO_SERVER_NAME'], - server_port=int(os.environ['GRADIO_SERVER_PORT']), - share=False - ) - else: - print("❌ No 'demo' object found in app module") - sys.exit(1) - + # The app will handle environment variables and launch automatically + print("🎯 TRELLIS will launch with environment variables...") + except Exception as e: print(f"❌ Error launching TRELLIS: {e}") traceback.print_exc() diff --git a/services/trellis/source b/services/trellis/source index f17fdf1..1fc6f1f 160000 --- a/services/trellis/source +++ b/services/trellis/source @@ -1 +1 @@ -Subproject commit f17fdf12d8f17a6a09225f01756d141285dc848f +Subproject commit 1fc6f1f9e378f45892331f5180bb186d6bea6d00 diff --git a/services/trellis/startup.sh b/services/trellis/startup.sh index 44cf64e..b7e63ce 100644 --- a/services/trellis/startup.sh +++ b/services/trellis/startup.sh @@ -4,14 +4,10 @@ source ~/.venv/bin/activate ./post_install.sh -echo "Attempting to start TRELLIS on $GRADIO_SERVER_NAME:$GRADIO_SERVER_PORT" - -# Set environment variables for Gradio -export GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-"0.0.0.0"} -export GRADIO_SERVER_PORT=${GRADIO_SERVER_PORT:-"7860"} +echo "Attempting to start TRELLIS on ${GRADIO_SERVER_NAME:-0.0.0.0}:${GRADIO_SERVER_PORT:-7860}" # Ensure we're in the correct directory cd /home/trellis/app -# Launch TRELLIS using the simple wrapper +# Launch TRELLIS using the wrapper (contains Gradio patch) python3 app_wrapper.py From 57363878631e448784b1c3927220a88ce7524414 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 16:57:47 -0700 Subject: [PATCH 2/3] update wrapper --- services/trellis/app_wrapper.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/services/trellis/app_wrapper.py b/services/trellis/app_wrapper.py index 5aecbe6..062c109 100644 --- a/services/trellis/app_wrapper.py +++ b/services/trellis/app_wrapper.py @@ -60,8 +60,22 @@ def main(): import app print("✅ TRELLIS app imported successfully") - # The app will handle environment variables and launch automatically - print("🎯 TRELLIS will launch with environment variables...") + # Initialize the pipeline and launch the app + print("🎯 Initializing TRELLIS pipeline...") + from trellis.pipelines import TrellisImageTo3DPipeline + + pipeline = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large") + pipeline.cuda() + + # Set the pipeline as a global variable in the app module + app.pipeline = pipeline + + print("🎯 Launching TRELLIS Gradio interface...") + app.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' + ) except Exception as e: print(f"❌ Error launching TRELLIS: {e}") From 7b98895bb07aee24d96196ba36ca411208253e47 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 14 Jul 2025 17:22:01 -0700 Subject: [PATCH 3/3] update sub --- services/trellis/source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/trellis/source b/services/trellis/source index 1fc6f1f..d43582f 160000 --- a/services/trellis/source +++ b/services/trellis/source @@ -1 +1 @@ -Subproject commit 1fc6f1f9e378f45892331f5180bb186d6bea6d00 +Subproject commit d43582f51d0acfdc2c73bdc46303f18c3f4c67c4