nexusbert commited on
Commit
5d4d48e
·
1 Parent(s): c32d298
Files changed (3) hide show
  1. Dockerfile +7 -1
  2. app.py +3 -0
  3. renderer.py +8 -1
Dockerfile CHANGED
@@ -7,7 +7,9 @@ ARG HF_TOKEN
7
  ENV DEBIAN_FRONTEND=noninteractive \
8
  PYTHONUNBUFFERED=1 \
9
  PYTHONDONTWRITEBYTECODE=1 \
10
- HF_TOKEN=${HF_TOKEN}
 
 
11
 
12
  WORKDIR /code
13
 
@@ -20,6 +22,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
20
  libomp-dev \
21
  libosmesa6-dev \
22
  libglib2.0-0 \
 
 
 
 
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
  # Copy requirements and install Python dependencies
 
7
  ENV DEBIAN_FRONTEND=noninteractive \
8
  PYTHONUNBUFFERED=1 \
9
  PYTHONDONTWRITEBYTECODE=1 \
10
+ HF_TOKEN=${HF_TOKEN} \
11
+ PYOPENGL_PLATFORM=osmesa \
12
+ DISPLAY=:99
13
 
14
  WORKDIR /code
15
 
 
22
  libomp-dev \
23
  libosmesa6-dev \
24
  libglib2.0-0 \
25
+ libx11-6 \
26
+ libxext6 \
27
+ libxrender1 \
28
+ libgl1-mesa-dri \
29
  && rm -rf /var/lib/apt/lists/*
30
 
31
  # Copy requirements and install Python dependencies
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  from fastapi import FastAPI, HTTPException
2
  from fastapi.responses import StreamingResponse
3
  from pydantic import BaseModel, Field
 
1
+ import os
2
+ os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
3
+
4
  from fastapi import FastAPI, HTTPException
5
  from fastapi.responses import StreamingResponse
6
  from pydantic import BaseModel, Field
renderer.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import numpy as np
2
  import pyrender
3
  import trimesh
@@ -14,7 +17,11 @@ class AvatarRenderer:
14
  self.image_size = image_size
15
  self.camera_type = camera_type
16
  self.light_intensity = light_intensity
17
- self.renderer = pyrender.OffscreenRenderer(image_size, image_size)
 
 
 
 
18
 
19
  def render(
20
  self,
 
1
+ import os
2
+ os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
3
+
4
  import numpy as np
5
  import pyrender
6
  import trimesh
 
17
  self.image_size = image_size
18
  self.camera_type = camera_type
19
  self.light_intensity = light_intensity
20
+ self.renderer = pyrender.OffscreenRenderer(
21
+ viewport_width=image_size,
22
+ viewport_height=image_size,
23
+ point_size=1.0
24
+ )
25
 
26
  def render(
27
  self,