Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# coding: utf8
from __future__ import unicode_literals
import prodigy
from prodigy.components.loaders import Images
from prodigy.util import split_string
from prodigy.util import set_hashes
from prodigy.components.db import connect
import itertools
def update(answers):
for answer in answers:
for option in answer['options']:
del option['image']
# print('answer:', answer)
# Recipe decorator with argument annotations: (description, argument type,
# shortcut, type / converter function called on value before it's passed to
# the function). Descriptions are also shown when typing --help.
dataset=("The dataset to use", "positional", None, str),
source=("Path to a directory of images", "positional", None, str),
def multi_image_classification(dataset, source):
tmp = Images(source)
stream = []
it = 0
tID = 1
x = {}
for task in tmp:
if it == 0:
x = {}
x['label'] = 'DIY'
x['id'] = tID
x['options'] = []
x['options'].append({'id': it, 'text': task['meta']['file'] ,'image': task['image']})
if it == 3:
it = 0
tID += 1
it += 1
if it > 0:
return {
'view_id': 'choice', # Annotation interface to use
'dataset': dataset, # Name of dataset to save annotations
'update': update,
'stream': stream, # Incoming stream of examples
'config': { # Additional config settings
'choice_style': 'multiple',
'choice_auto_accept': False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.