RU
Простая не обученая модель перевода текста в число.
EN
A simple untrained model for translating text to number.
Usage:
!pip install huggingface_hub
import keras
from huggingface_hub import hf_hub_download
import tensorflow as tf
def text_to_number(text: str, model):
temp = model(tf.expand_dims(tf.strings.unicode_decode(text,"UTF-8"),0))
temp = tf.keras.layers.Lambda(lambda x: tf.strings.to_number(tf.strings.substr(tf.strings.as_string(x), 7, 1)))(temp)
temp = temp.numpy().tolist()
temp = [int(x) for x in temp[0]]
temp = list(map(str, temp))
result = ""
for number in temp:
result = result + number
return result
# Download the model from Hugging Face Hub to a local directory.
model_path = hf_hub_download(repo_id="zelk12/text_in_number_converter", filename="Converter model.keras")
# Assuming the model was saved as 'saved_model.pb'
# Load the model using the local path.
model = keras.saving.load_model(model_path)
# Return number
text_to_number("Hello world.", model)
#Output: 2273715786
- Downloads last month
- 0