Stream text and images together

I need to upload multimodal data with text alongside image but unable to upload the image from local path as it shows, can't find file.

My code is :

`import prodigy
 from prodigy.components.loaders import JSONL

file_path=("Path to texts", "positional", None, str))
def sentiment(dataset, file_path):
"""Annotate the sentiment of texts using different mood options."""
stream = JSONL(file_path)     # load in the JSONL file

def update(examples):
    # this function is triggered when Prodigy receives annotations
    print("Received {} annotations!".format(len(examples)))

return {
    'dataset': dataset,   # save annotations in this dataset
    'view_id': 'html',  # use the choice interface
    'stream': stream,
    'update': update,
	'config' : {"html_template": "<img src='{{image}}' /><h2>{{title}}</h2><strong>{{data.label}}</strong><span style='background: #ffe184'>{{data.value}}</span>"}

And one of my json input is like:

{"title": "End ", "image": "image.jpg", "data": { "label": "Some label", "value": "This is a value" }, "meta": { "source": "Unsplash", "by": "Peter Nguyen", "url": "" }}

Hi! The problem here is that you're only providing a relative path to the image (relative to your Python script). Even if you used the absolute path of the image on your machine, modern browser typically block local file paths for images etc. for security reasons.

See my post here for more details on how to solve this:

I've created a local server and querying from that as you said. Its working fine for me know, thanks for the help !

1 Like