MohamedRashad commited on
Commit
4cf6a1b
·
1 Parent(s): d343412

Enhance headless rendering setup in app.py by adding necessary libraries and environment variables, and update usage instructions for 3D model preview in Chrome.

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -9,9 +9,18 @@ import lightning as L
9
  import spaces
10
  import torch
11
  import yaml
12
- from box import Box
13
 
14
- subprocess.run("apt update && apt install -y libegl1-mesa libgles2-mesa libosmesa6 libgl1-mesa-glx", shell=True)
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Get the PyTorch and CUDA versions
17
  torch_version = torch.__version__.split("+")[0] # Strips any "+cuXXX" suffix
@@ -355,6 +364,7 @@ def create_app():
355
 
356
  # Usage Instructions Section
357
  gr.Markdown("""## Notes:
 
358
  - Supported File Formats are `.obj`, `.fbx`, `.glb`
359
  - The process may take a few minutes depending on the model complexity and server load.
360
  """)
 
9
  import spaces
10
  import torch
11
  import yaml
 
12
 
13
+ subprocess.run("apt update && apt install -y libegl1-mesa-dev libgles2-mesa-dev libosmesa6-dev libgl1-mesa-glx libglu1-mesa-dev libglfw3-dev libglew-dev xvfb", shell=True)
14
+
15
+ # Set environment variables for headless rendering
16
+ import os
17
+ os.environ['PYOPENGL_PLATFORM'] = 'egl'
18
+ os.environ['DISPLAY'] = ':99'
19
+
20
+ # Start virtual display for headless rendering
21
+ subprocess.run("Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &", shell=True)
22
+
23
+ from box import Box
24
 
25
  # Get the PyTorch and CUDA versions
26
  torch_version = torch.__version__.split("+")[0] # Strips any "+cuXXX" suffix
 
364
 
365
  # Usage Instructions Section
366
  gr.Markdown("""## Notes:
367
+ - If you are not seeing the 3D model preview and you are using chrome, go to `chrome://flags/#enable-unsafe-webgpu` and enable the flag.
368
  - Supported File Formats are `.obj`, `.fbx`, `.glb`
369
  - The process may take a few minutes depending on the model complexity and server load.
370
  """)