Abdulrahman1989 commited on
Commit
531cd4b
·
1 Parent(s): 9d98595

Fix render issue

Browse files
Files changed (2) hide show
  1. Image3DProcessor.py +6 -3
  2. app.py +1 -3
Image3DProcessor.py CHANGED
@@ -101,13 +101,16 @@ class Image3DProcessor:
101
  rendered_image = t_to_512(rendered_image)
102
  loop_renders.append(torch.clamp(rendered_image * 255, 0.0, 255.0).detach().permute(1, 2, 0).cpu().numpy().astype(np.uint8))
103
 
104
- # Save the mesh and video in memory and return them as byte arrays
105
  mesh_buffer = BytesIO()
106
- export_to_obj(mesh_buffer, reconstruction_unactivated) # Function that saves mesh to an in-memory buffer
 
107
  mesh_data = mesh_buffer.getvalue()
108
 
 
109
  video_buffer = BytesIO()
110
  imageio.mimwrite(video_buffer, loop_renders, format='mp4', fps=30)
 
111
  video_data = video_buffer.getvalue()
112
 
113
- return mesh_data, video_data
 
101
  rendered_image = t_to_512(rendered_image)
102
  loop_renders.append(torch.clamp(rendered_image * 255, 0.0, 255.0).detach().permute(1, 2, 0).cpu().numpy().astype(np.uint8))
103
 
104
+ # Save the mesh to an in-memory buffer
105
  mesh_buffer = BytesIO()
106
+ export_to_obj(mesh_buffer, reconstruction) # Ensure `export_to_obj()` can write to `BytesIO`
107
+ mesh_buffer.seek(0) # Reset buffer position for reading
108
  mesh_data = mesh_buffer.getvalue()
109
 
110
+ # Save video to an in-memory buffer
111
  video_buffer = BytesIO()
112
  imageio.mimwrite(video_buffer, loop_renders, format='mp4', fps=30)
113
+ video_buffer.seek(0) # Reset buffer position for reading
114
  video_data = video_buffer.getvalue()
115
 
116
+ return mesh_data, video_data
app.py CHANGED
@@ -6,7 +6,6 @@ from SDXLImageGenerator import SDXLImageGenerator # Import your existing class
6
  import sys
7
  from Image3DProcessor import Image3DProcessor # Import your 3D processing class
8
 
9
-
10
  class ControlNetProcessor:
11
  def controlnet_image(self, image):
12
  # Placeholder for ControlNet processing (e.g., returning a processed image or placeholder text)
@@ -40,12 +39,11 @@ class GradioApp:
40
  # controlled_image = self.controlnet_processor.controlnet_image(initial_image)
41
  mesh_data, video_data = self.video_generator.generate_3d_video(initial_image)
42
 
43
- # Create a temporary file to display the mesh content
44
  with tempfile.NamedTemporaryFile(delete=False, suffix=".obj") as mesh_file:
45
  mesh_file.write(mesh_data)
46
  mesh_path = mesh_file.name
47
 
48
- # Create a temporary file to display the video content
49
  with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as video_file:
50
  video_file.write(video_data)
51
  video_path = video_file.name
 
6
  import sys
7
  from Image3DProcessor import Image3DProcessor # Import your 3D processing class
8
 
 
9
  class ControlNetProcessor:
10
  def controlnet_image(self, image):
11
  # Placeholder for ControlNet processing (e.g., returning a processed image or placeholder text)
 
39
  # controlled_image = self.controlnet_processor.controlnet_image(initial_image)
40
  mesh_data, video_data = self.video_generator.generate_3d_video(initial_image)
41
 
42
+ # Create temporary files to display mesh and video content
43
  with tempfile.NamedTemporaryFile(delete=False, suffix=".obj") as mesh_file:
44
  mesh_file.write(mesh_data)
45
  mesh_path = mesh_file.name
46
 
 
47
  with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as video_file:
48
  video_file.write(video_data)
49
  video_path = video_file.name