# Path: deepanimebot/decorators.py
# def timeout(max_timeout):
#     """Timeout decorator, parameter in seconds."""
#     def timeout_decorator(f):
#         """Wrap the original function."""
#         @functools.wraps(f)
#         def func_wrapper(self, *args, **kwargs):
#             """Closure for function."""
#             pool = multiprocessing.pool.ThreadPool(processes=1)
#             async_result = pool.apply_async(f, (self,) + args, kwargs)
#             timeout = kwargs.pop('timeout_max_timeout', max_timeout) or max_timeout
#             # raises a TimeoutError if execution exceeds max_timeout
#             return async_result.get(timeout)
#         return func_wrapper
#     return timeout_decorator
# 
# Path: deepanimebot/shortcuts.py
# def at_random(*messages):
#     return random.choice(messages)


import cv2
import numpy as np
import h5py
import requests
import data
import deploy
from .decorators import timeout
from . import exceptions as exc
from .shortcuts import at_random
            input_shape=input_shape,
            n_outputs=len(catname_to_categories),
            model_name=model_name)
        self.input_shape = input_shape
        self.average_image = data.get_mean(dataset_path)

    def classify(self, cvimage):
        normalized = deploy.normalize_cvimage(cvimage, size=self.input_shape, mean=self.average_image)
        return deploy.apply_model(normalized, self.model, self.category_to_catnames)


class URLClassifier(object):
    def __init__(self, image_classifier):
        self._image_classifier = image_classifier

    def classify(self, url=None):
        cvimage = fetch_cvimage_from_url(url)

        if cvimage is None:
            raise exc.NotImage(url)

        return self._image_classifier.classify(cvimage)


class RemoteClassifier(object):
    def __init__(self, base_url):
        self._base_url = base_url

    def classify(self, **params):
        try:

# Path: deepanimebot/decorators.py
# def timeout(max_timeout):
#     """Timeout decorator, parameter in seconds."""
#     def timeout_decorator(f):
#         """Wrap the original function."""
#         @functools.wraps(f)
#         def func_wrapper(self, *args, **kwargs):
#             """Closure for function."""
#             pool = multiprocessing.pool.ThreadPool(processes=1)
#             async_result = pool.apply_async(f, (self,) + args, kwargs)
#             timeout = kwargs.pop('timeout_max_timeout', max_timeout) or max_timeout
#             # raises a TimeoutError if execution exceeds max_timeout
#             return async_result.get(timeout)
#         return func_wrapper
#     return timeout_decorator
# 
# Path: deepanimebot/shortcuts.py
# def at_random(*messages):
#     return random.choice(messages)


# Path: deepanimebot/classifiers.py
import cv2
import numpy as np
import h5py
import requests
import data
import deploy
from .decorators import timeout
from . import exceptions as exc
from .shortcuts import at_random

            input_shape=input_shape,
            n_outputs=len(catname_to_categories),
            model_name=model_name)
        self.input_shape = input_shape
        self.average_image = data.get_mean(dataset_path)

    def classify(self, cvimage):
        normalized = deploy.normalize_cvimage(cvimage, size=self.input_shape, mean=self.average_image)
        return deploy.apply_model(normalized, self.model, self.category_to_catnames)


class URLClassifier(object):
    def __init__(self, image_classifier):
        self._image_classifier = image_classifier

    def classify(self, url=None):
        cvimage = fetch_cvimage_from_url(url)

        if cvimage is None:
            raise exc.NotImage(url)

        return self._image_classifier.classify(cvimage)


class RemoteClassifier(object):
    def __init__(self, base_url):
        self._base_url = base_url

    def classify(self, **params):
        try:

            r = requests.get(self._base_url, params=params, timeout=60).json()