Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,7 @@ y = y[:100000]
|
|
| 50 |
|
| 51 |
# Define a function to generate text using the model
|
| 52 |
|
| 53 |
-
def generate_text(
|
| 54 |
# Check if the start text is not None and has a non-empty string value
|
| 55 |
if start_text is not None and start_text.strip():
|
| 56 |
# Convert the start text to a sequence of indices
|
|
@@ -60,7 +60,7 @@ def generate_text(model, start_text, num_words):
|
|
| 60 |
# Generate words using the model until reaching the desired length or an end token
|
| 61 |
output_text = start_text + " "
|
| 62 |
end_tokens = [".", "?", "!"] # tokens that indicate the end of a sentence
|
| 63 |
-
|
| 64 |
for i in range(num_words):
|
| 65 |
# Predict the next word using the model
|
| 66 |
output_seq = model.predict(input_seq)
|
|
|
|
| 50 |
|
| 51 |
# Define a function to generate text using the model
|
| 52 |
|
| 53 |
+
def generate_text(start_text):
|
| 54 |
# Check if the start text is not None and has a non-empty string value
|
| 55 |
if start_text is not None and start_text.strip():
|
| 56 |
# Convert the start text to a sequence of indices
|
|
|
|
| 60 |
# Generate words using the model until reaching the desired length or an end token
|
| 61 |
output_text = start_text + " "
|
| 62 |
end_tokens = [".", "?", "!"] # tokens that indicate the end of a sentence
|
| 63 |
+
num_words = len(start_text.split())
|
| 64 |
for i in range(num_words):
|
| 65 |
# Predict the next word using the model
|
| 66 |
output_seq = model.predict(input_seq)
|