Spaces:
Sleeping
Sleeping
Update app.py
Browse files29 unmodified lines303132333334353637373839408 unmodified lines49505152535455555657585956575859606129 unmodified lines return frames
# Function to generate text descriptions for framesdef generate_descriptions_for_frames(video_path):def generate_descriptions_for_frames(video_path, user_prompt): frames = frame_capture(video_path) images = [PIL.Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) for frame in frames] prompt = "Describe what is happening in each of these frames in this video sequentially." prompt = f"Describe what is happening in each of these frames in this video sequentially. {user_prompt}" images_with_prompt = [prompt] + images responses = model.generate_content(images_with_prompt)8 unmodified lines
# Define Gradio interfacevideo_input = gr.Video(label="Upload Video", autoplay=True)user_input = gr.Textbox(label="Ask something specific about the video", placeholder="E.g., Are there any cars in this video?")output_text = gr.Textbox(label="What's in this video")
# Create Gradio appgr.Interface(fn=generate_descriptions_for_frames, inputs=video_input, outputs=output_text, title="Video Analysis System").launch()
gr.Interface( fn=generate_descriptions_for_frames, inputs=[video_input, user_input], outputs=output_text, title="Interactive Video Analysis System").launch()app.py+9-7