RU

Простая не обученая модель перевода текста в число.

EN

A simple untrained model for translating text to number.

Model: "Test_model"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Layer (type)                          Output Shape                         Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ input_layer_2 (InputLayer)           │ (None, None)                │               0 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ embedding_2 (Embedding)              │ (None, None, 1)             │         500,000 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ gru_2 (GRU)                          │ (None, 128)                 │          50,304 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dense_2 (Dense)                      │ (None, 10)                  │           1,290 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ reshape_2 (Reshape)                  │ (None, 10)                  │               0 │
└──────────────────────────────────────┴─────────────────────────────┴─────────────────┘
 Total params: 551,594 (2.10 MB)
 Trainable params: 551,594 (2.10 MB)
 Non-trainable params: 0 (0.00 B)

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
22
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no pipeline_tag.