dkatz2391 commited on
Commit
8fec6b4
·
verified ·
1 Parent(s): 696b9f6
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -1,11 +1,9 @@
1
- # Version: 1.1.0 - API State Fix + DEBUG (Video Disabled - Corrected Baseline) (2025-05-04)
2
  # Changes:
3
- # - Based *EXACTLY* on user-provided Version 1.1.0 code.
4
  # - TEMPORARY DEBUGGING STEP: Commented out video rendering/saving in `text_to_3d`
5
  # and return None for video_path to isolate the "Session not found" error.
6
- # - All other code (imports, functions, UI bindings, pipeline loading) is from Version 1.1.0.
7
- # - Removed incorrect `torch_dtype` argument from pipeline loading.
8
- # - Removed incorrect `inputs`/`outputs` arguments from `demo.unload()`.
9
 
10
  import gradio as gr
11
  # NOTE: Ensuring 'spaces' is imported if decorators are used (was missing in user provided snippet but needed)
@@ -16,7 +14,7 @@ import spaces
16
  import os
17
  import shutil
18
  os.environ['TOKENIZERS_PARALLELISM'] = 'true'
19
- os.environ['SPCONV_ALGO'] = 'native' # Direct set as per original
20
 
21
  from typing import *
22
  import torch
@@ -383,6 +381,7 @@ with gr.Blocks(delete_cache=(600, 600), title="TRELLIS Text-to-3D") as demo:
383
  *NOTE: Gaussian file (.ply) can be very large (~50MB+) and may take time to process/download.*
384
  """)
385
  with gr.Column(scale=1):
 
386
  video_output = gr.Video(label="Generated 3D Preview (DISABLED FOR DEBUG)", autoplay=False, loop=False, value=None, height=350)
387
  model_output = gr.Model3D(label="Extracted Model Preview", height=350, clear_color=[0.95, 0.95, 0.95, 1.0])
388
  with gr.Row():
@@ -391,8 +390,10 @@ with gr.Blocks(delete_cache=(600, 600), title="TRELLIS Text-to-3D") as demo:
391
 
392
  # --- Event Handlers ---
393
  print("Defining Gradio event handlers...")
394
- demo.load(start_session) # Removed inputs/outputs kwargs, they are optional
395
- demo.unload(end_session) # Removed incorrect inputs/outputs kwargs
 
 
396
 
397
  generate_event = generate_btn.click(
398
  get_seed,
@@ -402,7 +403,7 @@ with gr.Blocks(delete_cache=(600, 600), title="TRELLIS Text-to-3D") as demo:
402
  ).then(
403
  text_to_3d,
404
  inputs=[text_prompt, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps],
405
- outputs=[output_buf, video_output],
406
  api_name="text_to_3d"
407
  ).then(
408
  lambda: (
@@ -458,10 +459,9 @@ if __name__ == "__main__":
458
  pipeline = None
459
  pipeline_loaded = False
460
  try:
461
- # --- Load pipeline WITHOUT torch_dtype ---
462
  pipeline = TrellisTextTo3DPipeline.from_pretrained(
463
  "JeffreyXiang/TRELLIS-text-xlarge"
464
- # Removed: torch_dtype=torch.float16
465
  )
466
  if torch.cuda.is_available():
467
  pipeline = pipeline.to("cuda")
@@ -478,6 +478,7 @@ if __name__ == "__main__":
478
 
479
  if pipeline_loaded:
480
  print("Launching Gradio demo...")
 
481
  demo.queue().launch(debug=True)
482
  print("Gradio demo launched.")
483
  else:
 
1
+ # Version: 1.1.0 - API State Fix + DEBUG (Video Disabled - FINAL CORRECTED BASELINE) (2025-05-04)
2
  # Changes:
3
+ # - Based *EXACTLY* on user-provided Version 1.1.0 code that fixed state dict & loaded pipeline.
4
  # - TEMPORARY DEBUGGING STEP: Commented out video rendering/saving in `text_to_3d`
5
  # and return None for video_path to isolate the "Session not found" error.
6
+ # - No other changes were made. Removed previous erroneous additions.
 
 
7
 
8
  import gradio as gr
9
  # NOTE: Ensuring 'spaces' is imported if decorators are used (was missing in user provided snippet but needed)
 
14
  import os
15
  import shutil
16
  os.environ['TOKENIZERS_PARALLELISM'] = 'true'
17
+ os.environ['SPCONV_ALGO'] = 'native' # Direct set as per original user code
18
 
19
  from typing import *
20
  import torch
 
381
  *NOTE: Gaussian file (.ply) can be very large (~50MB+) and may take time to process/download.*
382
  """)
383
  with gr.Column(scale=1):
384
+ # Video component remains for layout but won't show anything in this debug version
385
  video_output = gr.Video(label="Generated 3D Preview (DISABLED FOR DEBUG)", autoplay=False, loop=False, value=None, height=350)
386
  model_output = gr.Model3D(label="Extracted Model Preview", height=350, clear_color=[0.95, 0.95, 0.95, 1.0])
387
  with gr.Row():
 
390
 
391
  # --- Event Handlers ---
392
  print("Defining Gradio event handlers...")
393
+ # Use demo.load as in original user-provided code
394
+ demo.load(start_session, inputs=None, outputs=None)
395
+ # Use demo.unload as in original user-provided code (no extra args)
396
+ demo.unload(end_session) # Corrected: removed inputs/outputs
397
 
398
  generate_event = generate_btn.click(
399
  get_seed,
 
403
  ).then(
404
  text_to_3d,
405
  inputs=[text_prompt, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps],
406
+ outputs=[output_buf, video_output], # state_dict -> output_buf, None -> video_output
407
  api_name="text_to_3d"
408
  ).then(
409
  lambda: (
 
459
  pipeline = None
460
  pipeline_loaded = False
461
  try:
462
+ # --- Load pipeline WITHOUT torch_dtype (As per original working version) ---
463
  pipeline = TrellisTextTo3DPipeline.from_pretrained(
464
  "JeffreyXiang/TRELLIS-text-xlarge"
 
465
  )
466
  if torch.cuda.is_available():
467
  pipeline = pipeline.to("cuda")
 
478
 
479
  if pipeline_loaded:
480
  print("Launching Gradio demo...")
481
+ # Use queue and debug=True as in original user-provided code
482
  demo.queue().launch(debug=True)
483
  print("Gradio demo launched.")
484
  else: