Spaces:
Sleeping
Sleeping
File size: 1,391 Bytes
62789ac 59da1a5 65367ab 62789ac 65367ab 62789ac 65367ab 62789ac 65367ab 62789ac 65367ab 3afeae4 62789ac 65367ab 62789ac 65367ab 62789ac 65367ab 59da1a5 62789ac 59da1a5 62789ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import gradio as gr
from gradio_client import Client, handle_file
# Function to handle video-to-image extraction and return the extracted frames as a ZIP
def extract_frames_from_video(video_file):
# Initialize the client for Video-To-Image API
client = Client("Abu1998/Video-To-Image")
# Upload the video file to the API
video_url = handle_file(video_file.name)
# Send the video file to the API for processing
result = client.predict(
video_path={"video": video_url},
api_name="/predict"
)
# The result should contain the link to the ZIP file with extracted frames
return result['filepath']
# Gradio Interface setup
def create_gradio_interface():
with gr.Blocks() as app:
gr.Markdown("# Video to Image Frame Extractor")
# Input component for video upload
video_file = gr.File(type="filepath", label="Upload Video")
# Output component for the extracted frames (ZIP file)
zip_output = gr.File(label="Download Extracted Frames as ZIP")
# Button to trigger video-to-image extraction
process_button = gr.Button("Extract Frames")
# Action for button click
process_button.click(fn=extract_frames_from_video, inputs=video_file, outputs=zip_output)
app.launch(share=True)
# Run the application
if __name__ == "__main__":
create_gradio_interface()
|