Spaces:
Sleeping
Sleeping
Update app.py
Browse files29 unmodified lines30313233343536373839408 unmodified lines495051525354555657585929 unmodified linesreturn frames# Function to generate text descriptions for framesdef generate_descriptions_for_frames(video_path):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."images_with_prompt = [prompt] + imagesresponses = model.generate_content(images_with_prompt)8 unmodified lines# Define Gradio interfacevideo_input = gr.Video(label="Upload Video", autoplay=True)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()29 unmodified lines30313233343536373839408 unmodified lines4950515253545556575859606129 unmodified linesreturn frames# Function to generate text descriptions for framesdef 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 = f"Describe what is happening in each of these frames in this video sequentially. {user_prompt}"images_with_prompt = [prompt] + imagesresponses = 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, user_input],outputs=output_text,title="Interactive Video Analysis System").launch()
app.py+9-7