wishwakankanamg commited on
Commit
ea6600d
·
1 Parent(s): 868aac5

attempt to load file from local for 3d compoentn

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -338,6 +338,27 @@ def display_initial_greeting(is_new_user_state_value: bool):
338
  # and the flag remains False.
339
  return [], False
340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
 
342
  CSS = """
343
  footer {visibility: hidden}
@@ -512,11 +533,7 @@ if __name__ == "__main__":
512
  )
513
  gr.Examples(
514
  label="Example 3D Models",
515
- examples=[
516
- [os.path.join(os.path.dirname(__file__), "files/Bunny.obj")],
517
- [os.path.join(os.path.dirname(__file__), "files/Fox.gltf")],
518
- [os.path.join(os.path.dirname(__file__), "files/face.obj")],
519
- ],
520
  inputs=gr.File(visible=False), # Dummy input for examples to load into Model3D
521
  outputs=model_3d_output,
522
  fn=load_mesh,
 
338
  # and the flag remains False.
339
  return [], False
340
 
341
+ def get_sorted_3d_model_examples():
342
+ examples_dir = Path("./generated_3d_models")
343
+ if not examples_dir.exists():
344
+ return []
345
+
346
+ # Get all 3D model files with desired extensions
347
+ model_files = [
348
+ file for file in examples_dir.glob("*")
349
+ if file.suffix.lower() in {".obj", ".glb", ".gltf"}
350
+ ]
351
+
352
+ # Sort files by creation time (latest first)
353
+ sorted_files = sorted(
354
+ model_files,
355
+ key=lambda x: x.stat().st_ctime,
356
+ reverse=True
357
+ )
358
+
359
+ # Convert to format [[path1], [path2], ...]
360
+ return [[str(file)] for file in sorted_files]
361
+
362
 
363
  CSS = """
364
  footer {visibility: hidden}
 
533
  )
534
  gr.Examples(
535
  label="Example 3D Models",
536
+ examples=get_sorted_3d_model_examples(),
 
 
 
 
537
  inputs=gr.File(visible=False), # Dummy input for examples to load into Model3D
538
  outputs=model_3d_output,
539
  fn=load_mesh,