krishnasivaborra commited on
Commit
22bdd2f
·
verified ·
1 Parent(s): 3ec1efa

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -48
app.py DELETED
@@ -1,48 +0,0 @@
1
- import gradio as gr
2
- import os
3
- import cv2
4
- from PIL import Image
5
- import tempfile
6
-
7
- def images_to_video(image_files, fps):
8
- temp_dir = tempfile.mkdtemp()
9
- image_paths = []
10
-
11
- # Save uploaded images to temp folder
12
- for idx, img in enumerate(image_files):
13
- img_path = os.path.join(temp_dir, f"img_{idx:03d}.png")
14
- Image.fromarray(img).save(img_path)
15
- image_paths.append(img_path)
16
-
17
- if not image_paths:
18
- return "No images uploaded!"
19
-
20
- # Get size from first image
21
- first_image = cv2.imread(image_paths[0])
22
- height, width, _ = first_image.shape
23
-
24
- video_path = os.path.join(temp_dir, "output_video.mp4")
25
- fourcc = cv2.VideoWriter_fourcc(*'mp4v')
26
- video = cv2.VideoWriter(video_path, fourcc, fps, (width, height))
27
-
28
- for path in image_paths:
29
- img = cv2.imread(path)
30
- video.write(img)
31
-
32
- video.release()
33
- return video_path
34
-
35
- # Gradio interface
36
- iface = gr.Interface(
37
- fn=images_to_video,
38
- inputs=[
39
- gr.File(file_types=["image"], file_count="multiple", label="Upload Images"),
40
- gr.Slider(minimum=1, maximum=60, value=10, label="FPS (frames per second)")
41
- ],
42
- outputs=gr.Video(label="Generated Video"),
43
- title="🖼️➡️🎥 Image to Video Converter",
44
- description="Upload a bunch of images and get a smooth slideshow video. Powered by OpenCV + Gradio!"
45
- )
46
-
47
- if __name__ == "__main__":
48
- iface.launch()