<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  palette.py
#  palette_detect
#

"""
Detect the main colors used in an image.
"""

import sys
import optparse
from collections import Counter, namedtuple
from operator import itemgetter, mul, attrgetter

import Image as Im
from colormath.color_objects import RGBColor

import multiprocessing

Color = namedtuple('Color', ['value', 'prominence'])
Palette = namedtuple('Palette', 'colors bgcolor')

N_COLORS = 32 # start with an adaptive palette of this size
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
THRESHOLD_DIST = 0.2 # max delta-e to merge two colors
SENTINEL = 'no more to process'
BLOCK_SIZE = 10
N_PROCESSES = 1

def color_stream_st(istream=sys.stdin):
    "Read filenames from the input stream and detect their palette."
    for line in istream:
        filename = line.strip()
        try:
            palette = extract_colors(filename)
        except Exception, e:
            print >> sys.stderr, filename, e
            continue

        print_colors(filename, palette)

def color_stream_mt(istream=sys.stdin, n=N_PROCESSES):
    """
    Read filenames from the input stream and detect their palette using
    multiple processes.
    """
    queue = multiprocessing.Queue(1000)
    lock = multiprocessing.Lock()

    pool = [multiprocessing.Process(target=color_process, args=(queue, lock))
            for i in xrange(n)]<commit_msg>Increase threshold for similarity to 2.0.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  palette.py
#  palette_detect
#

"""
Detect the main colors used in an image.
"""

import sys
import optparse
from collections import Counter, namedtuple
from operator import itemgetter, mul, attrgetter

import Image as Im
from colormath.color_objects import RGBColor

import multiprocessing

Color = namedtuple('Color', ['value', 'prominence'])
Palette = namedtuple('Palette', 'colors bgcolor')

N_COLORS = 32 # start with an adaptive palette of this size
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
THRESHOLD_DIST = 2.0 # max delta-e to merge two colors
SENTINEL = 'no more to process'
BLOCK_SIZE = 10
N_PROCESSES = 1

def color_stream_st(istream=sys.stdin):
    "Read filenames from the input stream and detect their palette."
    for line in istream:
        filename = line.strip()
        try:
            palette = extract_colors(filename)
        except Exception, e:
            print >> sys.stderr, filename, e
            continue

        print_colors(filename, palette)

def color_stream_mt(istream=sys.stdin, n=N_PROCESSES):
    """
    Read filenames from the input stream and detect their palette using
    multiple processes.
    """
    queue = multiprocessing.Queue(1000)
    lock = multiprocessing.Lock()

    pool = [multiprocessing.Process(target=color_process, args=(queue, lock))
            for i in xrange(n)]
{'fraction_non_alphanumeric': 0.0976123595505618, 'fraction_numerical': 0.0175561797752809, 'mean_word_length': 3.4239130434782608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1308496', 'n_tokens_mistral': 944, 'n_tokens_neox': 870, 'n_words': 286}