Exemple #1
0
def get_labels(img, model):
    masks, coords = get_characters(img)
    masks = array([
        dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:]) for mask in masks
    ])
    prediction = classifier.predict(model, masks)
    return [x for x in classifier_util.get_best_prediction(prediction)], coords
Exemple #2
0
def get_indicator_features(image, model):
    masks, lit = get_characters(image)
    masks = [
        dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:]) for mask in masks
    ]
    prediction = classifier.predict(model, np.array(masks))
    best_pred = classifier_util.get_best_prediction(prediction)
    return lit, format_label([classifier.LABELS[p] for p in best_pred])
Exemple #3
0
def get_password(img, model):
    masks = get_characters(img)
    masks = array([
        dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:]) for mask in masks
    ])
    prediction = classifier.predict(model, masks)
    best_pred = classifier_util.get_best_prediction(prediction)
    characters = [classifier.LABELS[x] for x in best_pred]
    return "".join(characters)
def get_serial_number(img, model):
    masks, alignment = get_characters(img)
    if not alignment:
        log("ERROR: Could not determine alignment of serial number",
            LOG_WARNING, "Serial Number")
        return None
    masks = np.array([
        dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:]) for mask in masks
    ])
    prediction = classifier.predict(model, masks)
    best_pred = classifier_util.get_best_prediction(prediction)
    return create_serial_string(best_pred, alignment)  # Return actual string.
Exemple #5
0
def get_details_async(model, holder):
    duration_masks = get_duration_characters()
    if len(duration_masks) != 3:
        log(f"WARNING: Bomb duration string length != 3 (len={len(get_duration_characters)}).",
            config.LOG_WARNING)
    module_masks = get_module_characters()
    masks = duration_masks + module_masks
    masks = np.array([dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:]) for mask in masks])
    prediction = classifier.predict(model, masks)
    best_pred = classifier_util.get_best_prediction(prediction)
    labels = [classifier.LABELS[p] for p in best_pred]
    holder.append(format_time(labels[:3]))
    holder.append(fix_number(labels[3:5]))
Exemple #6
0
def get_button_features(image, model):
    masks, color = get_characters(image)
    if len(masks) == 4:
        return "Hold", color
    elif len(masks) == 8:
        return "Detonate", color
    else:
        masks = np.array(
            [dataset_util.reshape(masks[0], config.CHAR_INPUT_DIM[1:])])
        prediction = classifier.predict(model, masks[0])
        best_pred = classifier_util.get_best_prediction(prediction)
        if classifier.LABELS[best_pred[0]] == "a":
            return "Abort", color
        return "Press", color
Exemple #7
0
def get_words(img, model):
    _, words, coords = get_characters(img)
    predictions = []
    for masks in words:
        result = " "
        if masks is not None:
            masks = np.array([
                dataset_util.reshape(mask, config.CHAR_INPUT_DIM[1:])
                for mask in masks
            ])
            prediction = classifier.predict(model, masks)
            result = get_word(prediction)
        predictions.append(result)
    return predictions, coords