Spaces:
Paused
Paused
Abdulrahman1989
commited on
Commit
·
66a8046
1
Parent(s):
0d6b1e2
Add VideoGenerator
Browse files
app.py
CHANGED
@@ -3,6 +3,9 @@ import tempfile
|
|
3 |
import os
|
4 |
from SDXLImageGenerator import SDXLImageGenerator # Import your existing class
|
5 |
import sys
|
|
|
|
|
|
|
6 |
os.system('bash setup.sh')
|
7 |
sys.path.append('./splatter-image')
|
8 |
sys.path.append('./diff-gaussian-rasterization')
|
@@ -10,26 +13,30 @@ sys.path.append('./diff-gaussian-rasterization')
|
|
10 |
class ControlNetProcessor:
|
11 |
def controlnet_image(self, image):
|
12 |
# Placeholder for ControlNet processing (e.g., returning a processed image or placeholder text)
|
13 |
-
return
|
14 |
|
15 |
class VideoGenerator:
|
16 |
-
def
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
video_path = tmp.name
|
26 |
return video_path
|
27 |
|
28 |
class GradioApp:
|
29 |
def __init__(self):
|
30 |
self.sdxl_generator = SDXLImageGenerator() # Use your existing class
|
31 |
self.controlnet_processor = ControlNetProcessor()
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def full_pipeline(self, prompt):
|
35 |
initial_image = self.sdxl_generator.generate_images([prompt])[0]
|
@@ -43,7 +50,7 @@ class GradioApp:
|
|
43 |
inputs=gr.Textbox(label="Input Prompt"),
|
44 |
outputs=[
|
45 |
gr.Image(label="Generated Image"),
|
46 |
-
gr.
|
47 |
gr.Video(label="3D Model Video")
|
48 |
],
|
49 |
title="SDXL to ControlNet to 3D Pipeline",
|
@@ -53,4 +60,4 @@ class GradioApp:
|
|
53 |
|
54 |
if __name__ == "__main__":
|
55 |
app = GradioApp()
|
56 |
-
app.launch()
|
|
|
3 |
import os
|
4 |
from SDXLImageGenerator import SDXLImageGenerator # Import your existing class
|
5 |
import sys
|
6 |
+
from Image3DProcessor import Image3DProcessor # Import your 3D processing class
|
7 |
+
|
8 |
+
# Ensure setup.sh runs and paths are appended
|
9 |
os.system('bash setup.sh')
|
10 |
sys.path.append('./splatter-image')
|
11 |
sys.path.append('./diff-gaussian-rasterization')
|
|
|
13 |
class ControlNetProcessor:
|
14 |
def controlnet_image(self, image):
|
15 |
# Placeholder for ControlNet processing (e.g., returning a processed image or placeholder text)
|
16 |
+
return image # Returning the image for further processing
|
17 |
|
18 |
class VideoGenerator:
|
19 |
+
def __init__(self, model_cfg_path, model_repo_id, model_filename):
|
20 |
+
# Initialize the Image3DProcessor
|
21 |
+
self.processor = Image3DProcessor(model_cfg_path, model_repo_id, model_filename)
|
22 |
+
|
23 |
+
def generate_3d_video(self, image):
|
24 |
+
# Process the image and create a 3D video
|
25 |
+
processed_image = self.processor.preprocess(image, preprocess_background=False)
|
26 |
+
mesh_path, video_path = self.processor.reconstruct_and_export(processed_image)
|
27 |
+
|
|
|
28 |
return video_path
|
29 |
|
30 |
class GradioApp:
|
31 |
def __init__(self):
|
32 |
self.sdxl_generator = SDXLImageGenerator() # Use your existing class
|
33 |
self.controlnet_processor = ControlNetProcessor()
|
34 |
+
# Initialize VideoGenerator with required paths and details
|
35 |
+
self.video_generator = VideoGenerator(
|
36 |
+
model_cfg_path="path/to/gradio_config.yaml",
|
37 |
+
model_repo_id="szymanowiczs/splatter-image-multi-category-v1",
|
38 |
+
model_filename="model_latest.pth"
|
39 |
+
)
|
40 |
|
41 |
def full_pipeline(self, prompt):
|
42 |
initial_image = self.sdxl_generator.generate_images([prompt])[0]
|
|
|
50 |
inputs=gr.Textbox(label="Input Prompt"),
|
51 |
outputs=[
|
52 |
gr.Image(label="Generated Image"),
|
53 |
+
gr.Image(label="ControlNet Processed Image"),
|
54 |
gr.Video(label="3D Model Video")
|
55 |
],
|
56 |
title="SDXL to ControlNet to 3D Pipeline",
|
|
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
app = GradioApp()
|
63 |
+
app.launch()
|