Visualize Results
- Text
- Image
- Audio
- Video
from IPython.display import Markdown, display
def visualize(item, source):
display(Markdown(item))
def show(results, output_key, get_original_callable=None):
for result in results:
source = None
if '_source' in result:
source = get_original_callable(result['_source'])
visualize(result[output_key], source)
from IPython.display import display
def visualize(item, source):
display(item) # item is a PIL.Image
def show(results, output_key, get_original_callable=None):
for result in results:
source = None
if '_source' in result:
source = get_original_callable(result['_source'])
visualize(result[output_key].x, source)
from IPython.display import Audio, display
def visualize(item, source):
display(Audio(item[1], fs=item[0]))
def show(results, output_key, get_original_callable=None):
for result in results:
source = None
if '_source' in result:
source = get_original_callable(result['_source'])
visualize(result[output_key], source)
from IPython.display import IFrame, display
def visualize(item, source):
display(item)
def show(results, output_key, get_original_callable=None):
for result in results:
source = None
if '_source' in result:
source = get_original_callable(result['_source'])
visualize(result[output_key], source)
from IPython.display import display, HTML
def visualize(uri, source):
timestamp = source # increment to the frame you want to start at
# Create HTML code for the video player with a specified source and controls
video_html = f"""
<video width="640" height="480" controls>
<source src="{uri}" type="video/mp4">
</video>
<script>
// Get the video element
var video = document.querySelector('video');
// Set the current time of the video to the specified timestamp
video.currentTime = {timestamp};
// Play the video automatically
video.play();
</script>
"""
display(HTML(video_html))
def show(results, output_key, get_original_callable=None):
# show only the first video
for result in results:
source = result['_source']
result = result[output_key]
timestamp = result['current_timestamp']
uri = get_original_callable(source)['x']
print(uri, timestamp)
visualize(uri, timestamp)
break