Exemple #1
0
def process_image():
    numbers = list(map(int, open('numbers.txt').read().split(' ')))
    o, _ = get_image('numbers.png')
    slices = [(s, 'green', n) for ((_, s), n) in zip(get_digits_fake(o), numbers)]
    ani = make_animation(o, slices, 300)
    # plt.show()
    return ani
Exemple #2
0
def process_image():
    numbers = list(map(int, open('numbers.txt').read().split(' ')))
    o, _ = get_image('numbers.png')
    slices = [(s, 'green', n)
              for ((_, s), n) in zip(get_digits_fake(o), numbers)]
    ani = make_animation(o, slices, 300)
    # plt.show()
    return ani
Exemple #3
0
def post_something():
    meme_path = request.args.get('meme')
    result_dict = {}
    if (not request.data):
        return "No data was sent !"
        # getting the image from client
    image_name = image_processing.get_image(request)

    # check if the file less than 1 MB
    if os.stat(image_name).st_size > 1000000:
        # reduce the size of the received image and delete the old one
        new_image_name = image_processing.get_image_less_than_1MB(image_name)
        os.remove(image_name)
    else:
        new_image_name = image_name
    predicted_label = predict_meme_class(new_image_name)
    return jsonify(predicted_label)
Exemple #4
0
def convert(image_file, text_file=None):
    img = ip.get_image(image_file)
    lines = []
    for line in ip.get_lines(img):
        words = []
        for word in ip.get_words(img, line):
            chars = []
            for char in ip.get_chars(img, word):
                c = convert_char(img, char)
                chars.append(c)
            words.append(''.join(chars))
        lines.append(' '.join(words))

    if text_file:
        f = open(text_file, 'w')
        f.write('\n'.join(lines))
        f.close()
    else:
        print '\n'.join(lines)
Exemple #5
0
def get_image_by_name(image_name, folder):
    return image_processing.get_image(image_name, folder)
Exemple #6
0
from digits_classifiers import get_predictor
from image_processing import get_digits, get_image
from utils import make_animation
import matplotlib.pylab as plt

predictor = get_predictor('Logistic regression')

original, img = get_image('numbers.png')

predictions = []
for digit, slice_ in get_digits(img):
    p = predictor.predict(digit)[0]
    predictions.append((slice_, 'green', p))

ani = make_animation(original, predictions, interval=300)
plt.show()