Abu1998's picture
Update app.py
3afeae4 verified
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()