I have a classifier model that predicts one of two labels for the input images. To perfect the model, I need to more tagged images to train further. For the ease of further labeling, I want to create a custom recipe that pre-annotates the image stream. This is the recipe I wrote,
@prodigy.recipe("tag-from-model")
def tag_from_model(dataset, images_path):
model = load_model()
blocks = [
{"view_id": "image"},
{"view_id": "text_input", "field_id": "caption", "field_autofocus": True},
]
def get_stream():
stream = Images(images_path)
for eg in stream:
caption = generate_caption(eg["image"], model)
eg["caption"] = caption
yield eg
return {
"dataset": dataset,
"stream": get_stream(),
"view_id": "blocks",
"config": {"blocks": blocks},
}
What I would like here is to display the model output as choice (exclusive) and not as a text input.
This is what I tried..
@prodigy.recipe("tag-from-model")
def tag_from_model(dataset, images_path):
model = load_model()
blocks = [
{"view_id": "image"},
{"view_id": "choice"},
]
options = [
{'id': 'VENT', 'text':'cat'},
{'id':'CARD', 'text':'dog'}
]
def get_stream():
stream = Images(images_path)
for eg in stream:
caption = generate_caption(eg["image"], model)
eg["options"] = caption
yield eg
return {
"dataset": dataset,
"stream": get_stream(),
"view_id": "blocks",
"config": {"blocks": blocks},
}
But this is obviously not going to work as there is no connection between the model output and the options block. I'm not able to figure out how..
I searched the support/documentation for similar questions, could not find any. Could you please help.
Thank you much
DU