def post(message): if "files" in message.body.keys(): labels = set() for file in message.body["files"]: label = animal.predict(file["url_private_download"]) if label is not None: f = File() f.add(file["permalink"], label) labels.add(label) for l in labels: message.react(animal.get_emoji(l))
import argparse import os import sys sys.path.append(os.path.abspath(".")) import animal from db import Database from file import File if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-u", help="url") parser.add_argument("-a", help="animal", choices=animal.CLASS_NAMES) args = parser.parse_args() Database.initialise() file = File() file.add(url=args.u, animal=args.a)