Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -38,6 +38,8 @@ except Exception as e:
|
|
38 |
model_weights = None
|
39 |
|
40 |
# Placeholder function - Replace with actual inference logic
|
|
|
|
|
41 |
def generate_video(prompt):
|
42 |
"""
|
43 |
Generates a placeholder video using the model.
|
@@ -46,18 +48,27 @@ def generate_video(prompt):
|
|
46 |
if model_weights is None:
|
47 |
return "Model failed to load. Please check the logs."
|
48 |
|
49 |
-
#
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
transform = transforms.ToTensor()
|
52 |
frame = (transform(img).permute(1, 2, 0).numpy() * 255).astype(np.uint8)
|
53 |
|
54 |
-
# Create a fake video with
|
55 |
-
frames = [frame] * 16 # 16 repeated frames
|
56 |
output_path = "output.mp4"
|
|
|
|
|
57 |
imageio.mimsave(output_path, frames, fps=8)
|
58 |
|
59 |
return output_path
|
60 |
|
|
|
61 |
# Gradio UI
|
62 |
iface = gr.Interface(
|
63 |
fn=generate_video,
|
|
|
38 |
model_weights = None
|
39 |
|
40 |
# Placeholder function - Replace with actual inference logic
|
41 |
+
import random
|
42 |
+
|
43 |
def generate_video(prompt):
|
44 |
"""
|
45 |
Generates a placeholder video using the model.
|
|
|
48 |
if model_weights is None:
|
49 |
return "Model failed to load. Please check the logs."
|
50 |
|
51 |
+
# Create a random color image as a frame
|
52 |
+
width, height = 512, 512
|
53 |
+
img = Image.new("RGB", (width, height),
|
54 |
+
color=(random.randint(0, 255),
|
55 |
+
random.randint(0, 255),
|
56 |
+
random.randint(0, 255))) # Random color
|
57 |
+
|
58 |
+
# Transform the image to a tensor and convert it to a numpy array
|
59 |
transform = transforms.ToTensor()
|
60 |
frame = (transform(img).permute(1, 2, 0).numpy() * 255).astype(np.uint8)
|
61 |
|
62 |
+
# Create a fake video with 16 frames, all having the same color
|
63 |
+
frames = [frame] * 16 # 16 repeated frames with different colors
|
64 |
output_path = "output.mp4"
|
65 |
+
|
66 |
+
# Save frames as a video with 8 fps
|
67 |
imageio.mimsave(output_path, frames, fps=8)
|
68 |
|
69 |
return output_path
|
70 |
|
71 |
+
|
72 |
# Gradio UI
|
73 |
iface = gr.Interface(
|
74 |
fn=generate_video,
|