Spaces:
Paused
Paused
Abdulrahman1989
commited on
Commit
·
30f0bac
1
Parent(s):
1c4ea7e
change Frontend to show image and video
Browse files
app.py
CHANGED
@@ -1,11 +1,57 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!"
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
|
9 |
|
10 |
if __name__ == "__main__":
|
11 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tempfile
|
3 |
+
import os
|
4 |
|
5 |
+
class SDXLGenerator:
|
6 |
+
def generate_image(self, prompt):
|
7 |
+
# Placeholder for image generation (e.g., returning a sample image or empty image)
|
8 |
+
return "Placeholder for Generated Image"
|
9 |
|
|
|
|
|
10 |
|
11 |
+
class ControlNetProcessor:
|
12 |
+
def controlnet_image(self, image):
|
13 |
+
# Placeholder for ControlNet processing (e.g., returning a sample image or empty image)
|
14 |
+
return "Placeholder for ControlNet Output Image"
|
15 |
+
|
16 |
+
|
17 |
+
class VideoGenerator:
|
18 |
+
def generate_3d_video(self, controlled_image):
|
19 |
+
# Placeholder: creating a dummy video for demonstration purposes.
|
20 |
+
video_path = "generated_video.mp4"
|
21 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tmp:
|
22 |
+
# Placeholder: creating a dummy video for demonstration purposes.
|
23 |
+
os.system(f"ffmpeg -f lavfi -i color=c=blue:s=320x240:d=5 -vf drawtext=fontfile=/path/to/font.ttf:text='3D Model':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2 {tmp.name}")
|
24 |
+
video_path = tmp.name
|
25 |
+
return video_path
|
26 |
+
|
27 |
+
|
28 |
+
class GradioApp:
|
29 |
+
def __init__(self):
|
30 |
+
self.sdxl_generator = SDXLGenerator()
|
31 |
+
self.controlnet_processor = ControlNetProcessor()
|
32 |
+
self.video_generator = VideoGenerator()
|
33 |
+
|
34 |
+
def full_pipeline(self, prompt):
|
35 |
+
initial_image = self.sdxl_generator.generate_image(prompt)
|
36 |
+
controlled_image = self.controlnet_processor.controlnet_image(initial_image)
|
37 |
+
video_path = self.video_generator.generate_3d_video(controlled_image)
|
38 |
+
return initial_image, controlled_image, video_path
|
39 |
+
|
40 |
+
def launch(self):
|
41 |
+
interface = gr.Interface(
|
42 |
+
fn=self.full_pipeline,
|
43 |
+
inputs=[gr.Textbox(label="Input Prompt")],
|
44 |
+
outputs=[
|
45 |
+
gr.Image(type="pil", label="Generated Image"),
|
46 |
+
gr.Image(type="pil", label="ControlNet Output Image"),
|
47 |
+
gr.Video(label="3D Model Video")
|
48 |
+
],
|
49 |
+
title="SDXL to ControlNet to 3D Pipeline",
|
50 |
+
description="Generate an image using SDXL, refine it with ControlNet, and generate a 3D video output."
|
51 |
+
)
|
52 |
+
interface.launch()
|
53 |
|
|
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
+
app = GradioApp()
|
57 |
+
app.launch()
|