DECIMER/Predictor_EfficientNet2.py
def evaluate(image_path: str):
    """
    This function takes an image path (str) and returns the SELFIES
    representation of the depicted molecule (str).

    Args:
        image_path (str): Path of chemical structure depiction image

    Returns:
        (str): SELFIES representation of the molecule in the input image
    """
    sample = config.decode_image(image_path)
    _image_batch = tf.expand_dims(sample, 0)
    _image_embedding = encoder(_image_batch, training=False)
    output = tf.expand_dims([tokenizer.word_index["<start>"]], 0)
    result = []
    end_token = tokenizer.word_index["<end>"]

    for i in range(MAX_LEN):
        combined_mask = Transformer_decoder.create_mask(None, output)
        prediction_batch, _ = transformer(
            _image_embedding, output, training=False, look_ahead_mask=combined_mask
        )

        predictions = prediction_batch[:, -1:, :]
        predicted_id = tf.cast(tf.argmax(predictions, axis=-1), tf.int32)

        if predicted_id == end_token:
            return result

        result.append(tokenizer.index_word[int(predicted_id)])
        output = tf.concat([output, predicted_id], axis=-1)

    return result

    This function takes an image path (str) and returns the SELFIES
    representation of the depicted molecule (str).

    Args:
        image_path (str): Path of chemical structure depiction image

    Returns:
        (str): SELFIES representation of the molecule in the input image
    
This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str).
This function takes an image path ( str ) and returns the SELFIES representation of the depicted molecule ( str ) .
def evaluate(image_path: str):
    sample = config.decode_image(image_path)
    _image_batch = tf.expand_dims(sample, 0)
    _image_embedding = encoder(_image_batch, training=False)
    output = tf.expand_dims([tokenizer.word_index["<start>"]], 0)
    result = []
    end_token = tokenizer.word_index["<end>"]
    for i in range(MAX_LEN):
        combined_mask = Transformer_decoder.create_mask(None, output)
        prediction_batch, _ = transformer(
            _image_embedding, output, training=False, look_ahead_mask=combined_mask
        )
        predictions = prediction_batch[:, -1:, :]
        predicted_id = tf.cast(tf.argmax(predictions, axis=-1), tf.int32)
        if predicted_id == end_token:
            return result
        result.append(tokenizer.index_word[int(predicted_id)])
        output = tf.concat([output, predicted_id], axis=-1)
    return result
def evaluate ( image_path : str ) : sample = config . decode_image ( image_path ) _image_batch = tf . expand_dims ( sample , 0 ) _image_embedding = encoder ( _image_batch , training = False ) output = tf . expand_dims ( [ tokenizer . word_index [ "<start>" ] ] , 0 ) result = [ ] end_token = tokenizer . word_index [ "<end>" ] for i in range ( MAX_LEN ) : combined_mask = Transformer_decoder . create_mask ( None , output ) prediction_batch , _ = transformer ( _image_embedding , output , training = False , look_ahead_mask = combined_mask ) predictions = prediction_batch [ : , - 1 : , : ] predicted_id = tf . cast ( tf . argmax ( predictions , axis = - 1 ) , tf . int32 ) if predicted_id == end_token : return result result . append ( tokenizer . index_word [ int ( predicted_id ) ] ) output = tf . concat ( [ output , predicted_id ] , axis = - 1 ) return result
This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str).
This function takes an image path ( str ) and returns the SELFIES representation of the depicted molecule ( str ) .
"""
    This function takes an image path (str) and returns the SELFIES
    representation of the depicted molecule (str).

    Args:
        image_path (str): Path of chemical structure depiction image

    Returns:
        (str): SELFIES representation of the molecule in the input image
    """
SELFIES representation of the molecule in the input image
SELFIES representation of the molecule in the input image
(str)
image_path
str
Path of chemical structure depiction image
Path of chemical structure depiction image