vgvm commited on
Commit
c98277f
1 Parent(s): 6341e72

small hf hack around for the gradio hack around

Browse files
Files changed (2) hide show
  1. app.py +16 -7
  2. meshin-around.sh +1 -1
app.py CHANGED
@@ -52,7 +52,7 @@ class face_image_to_face_mesh:
52
 
53
  The face depth with Zoe can be a bit much and without it is a bit generic. In blender you can fix this just by snapping to the high poly model.
54
 
55
- Highly recommend and running it locally. The 3D model has uv values in the faces, but you will have to make the mlt file manually at this point."
56
 
57
  Quick import result in examples/converted/movie-gallery.mp4 under files
58
  """)
@@ -204,9 +204,15 @@ class face_image_to_face_mesh:
204
  def toObj( self, image: np.ndarray, width:int, height:int, ratio: float, landmark_list: landmark_pb2.NormalizedLandmarkList, depth: np.ndarray, zoe_scale: float):
205
  print( f'you have such pretty hair', self.temp_dir )
206
 
207
- obj_file = tempfile.NamedTemporaryFile(suffix='.obj', dir=self.temp_dir, delete=False)
208
- mtl_file = tempfile.NamedTemporaryFile(suffix='.mtl', dir=self.temp_dir, delete=False)
209
- png_file = tempfile.NamedTemporaryFile(suffix='.png', dir=self.temp_dir, delete=False)
 
 
 
 
 
 
210
 
211
  ############################################
212
  (points,coordinates,colors) = self.landmarksToPoints( image, width, height, ratio, landmark_list, depth, zoe_scale )
@@ -216,8 +222,12 @@ class face_image_to_face_mesh:
216
 
217
  lines.append( f'o MyMesh' )
218
 
219
- # the 'file=' is a gradio hack
220
- lines.append( f'mtllib file={mtl_file.name}' )
 
 
 
 
221
 
222
  for index, point in enumerate(points):
223
  color = colors[index]
@@ -256,7 +266,6 @@ class face_image_to_face_mesh:
256
 
257
  lines = []
258
  lines.append( 'newmtl MyMaterial' )
259
- lines.append( 'illum 2' )
260
  lines.append( f'map_Kd file={png_file.name}' ) # the 'file=' is a gradio hack
261
 
262
  out = open( mtl_file.name, 'w' )
 
52
 
53
  The face depth with Zoe can be a bit much and without it is a bit generic. In blender you can fix this just by snapping to the high poly model.
54
 
55
+ Highly recommend running it locally. The 3D model has uv values in the faces, but you will have to make the mlt file manually at this point."
56
 
57
  Quick import result in examples/converted/movie-gallery.mp4 under files
58
  """)
 
204
  def toObj( self, image: np.ndarray, width:int, height:int, ratio: float, landmark_list: landmark_pb2.NormalizedLandmarkList, depth: np.ndarray, zoe_scale: float):
205
  print( f'you have such pretty hair', self.temp_dir )
206
 
207
+ hf_hack = True
208
+ if hf_hack:
209
+ obj_file = tempfile.NamedTemporaryFile(suffix='.obj', delete=False)
210
+ mtl_file = tempfile.NamedTemporaryFile(suffix='.mtl', delete=False)
211
+ png_file = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
212
+ else:
213
+ obj_file = tempfile.NamedTemporaryFile(suffix='.obj', dir=self.temp_dir, delete=False)
214
+ mtl_file = tempfile.NamedTemporaryFile(suffix='.mtl', dir=self.temp_dir, delete=False)
215
+ png_file = tempfile.NamedTemporaryFile(suffix='.png', dir=self.temp_dir, delete=False)
216
 
217
  ############################################
218
  (points,coordinates,colors) = self.landmarksToPoints( image, width, height, ratio, landmark_list, depth, zoe_scale )
 
222
 
223
  lines.append( f'o MyMesh' )
224
 
225
+ if hf_hack:
226
+ # the 'file=' is a gradio hack
227
+ lines.append( f'#mtllib file={mtl_file.name}' )
228
+ else:
229
+ # the 'file=' is a gradio hack
230
+ lines.append( f'mtllib file={mtl_file.name}' )
231
 
232
  for index, point in enumerate(points):
233
  color = colors[index]
 
266
 
267
  lines = []
268
  lines.append( 'newmtl MyMaterial' )
 
269
  lines.append( f'map_Kd file={png_file.name}' ) # the 'file=' is a gradio hack
270
 
271
  out = open( mtl_file.name, 'w' )
meshin-around.sh CHANGED
@@ -17,7 +17,7 @@ _meshin_around_main() {
17
  echo "${mash} already exists"
18
  else
19
  echo "creating ${mash} for ${mesh}"
20
- sed "s,^f.*,,;s,#f,f,;s,file=.*,${mtl}," ${mesh} > ${mash} || exit ${?}
21
  fi
22
 
23
  if [ -f "${mtl}" ] ; then
 
17
  echo "${mash} already exists"
18
  else
19
  echo "creating ${mash} for ${mesh}"
20
+ sed "s,^f.*,,;s,#f,f,;s,.*mtllib.*,mtllib ${mtl}," ${mesh} > ${mash} || exit ${?}
21
  fi
22
 
23
  if [ -f "${mtl}" ] ; then