Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -364,14 +364,14 @@ with open('model_google.pkl', 'rb') as f:
|
|
364 |
|
365 |
def Test_model(text, Model):
|
366 |
#print(text)
|
367 |
-
|
368 |
word_list = text_to_wordlist(text)
|
369 |
#print(word_list)
|
370 |
sequences = tokenizer.texts_to_sequences([word_list])
|
371 |
sequences_input = list(itertools.chain(*sequences))
|
372 |
|
373 |
-
if len(sequences_input) <=
|
374 |
-
sequences_input = pad_sequences([sequences_input], value=0, padding="post", maxlen=
|
375 |
#print(sequences_input)
|
376 |
input_a = np.asarray(sequences_input)
|
377 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
@@ -380,8 +380,8 @@ def Test_model(text, Model):
|
|
380 |
#print(labels[predicted_class])
|
381 |
else:
|
382 |
predictions = []
|
383 |
-
for i in range(len(sequences_input) -
|
384 |
-
window_input = sequences_input[i : i +
|
385 |
#print(window_input)
|
386 |
input_a = np.asarray([window_input])
|
387 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
@@ -404,8 +404,8 @@ def predict(text):
|
|
404 |
word_list = text_to_wordlist(text)
|
405 |
sequences = tokenizer.texts_to_sequences([word_list])
|
406 |
sequences_input = list(itertools.chain(*sequences))
|
407 |
-
if len(sequences_input) <=
|
408 |
-
sequences_input = pad_sequences([sequences_input], value=0, padding="post", maxlen=
|
409 |
#print(sequences_input)
|
410 |
input_a = np.asarray(sequences_input)
|
411 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
@@ -414,8 +414,8 @@ def predict(text):
|
|
414 |
#print(labels[predicted_class])
|
415 |
else:
|
416 |
predictions = []
|
417 |
-
for i in range(len(sequences_input) -
|
418 |
-
window_input = sequences_input[i : i +
|
419 |
#print(window_input)
|
420 |
input_a = np.asarray([window_input])
|
421 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
|
|
364 |
|
365 |
def Test_model(text, Model):
|
366 |
#print(text)
|
367 |
+
windows_size = 10
|
368 |
word_list = text_to_wordlist(text)
|
369 |
#print(word_list)
|
370 |
sequences = tokenizer.texts_to_sequences([word_list])
|
371 |
sequences_input = list(itertools.chain(*sequences))
|
372 |
|
373 |
+
if len(sequences_input) <= windows_size_size:
|
374 |
+
sequences_input = pad_sequences([sequences_input], value=0, padding="post", maxlen=windows_size).tolist()
|
375 |
#print(sequences_input)
|
376 |
input_a = np.asarray(sequences_input)
|
377 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
|
|
380 |
#print(labels[predicted_class])
|
381 |
else:
|
382 |
predictions = []
|
383 |
+
for i in range(len(sequences_input) - windows_size + 1):
|
384 |
+
window_input = sequences_input[i : i + windows_size]
|
385 |
#print(window_input)
|
386 |
input_a = np.asarray([window_input])
|
387 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
|
|
404 |
word_list = text_to_wordlist(text)
|
405 |
sequences = tokenizer.texts_to_sequences([word_list])
|
406 |
sequences_input = list(itertools.chain(*sequences))
|
407 |
+
if len(sequences_input) <= windows_size:
|
408 |
+
sequences_input = pad_sequences([sequences_input], value=0, padding="post", maxlen=windows_size).tolist()
|
409 |
#print(sequences_input)
|
410 |
input_a = np.asarray(sequences_input)
|
411 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|
|
|
414 |
#print(labels[predicted_class])
|
415 |
else:
|
416 |
predictions = []
|
417 |
+
for i in range(len(sequences_input) - windows_size + 1):
|
418 |
+
window_input = sequences_input[i : i + windows_size]
|
419 |
#print(window_input)
|
420 |
input_a = np.asarray([window_input])
|
421 |
pred = Modell.predict(input_a, batch_size=None, verbose=0, steps=None)
|