Open bag7dad opened 4 years ago
@medozeus here's a code you can addapt, mine is a simple terminal chatbot interface
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from main import * # import the main python file with model from the example
import time
load_weights = tl.files.load_npz(name='saved/model.npz')
tl.files.assign_weights(load_weights, model_)
def respond(input):
sentence = inference(input, 3)
response=' '.join(sentence)
return response
while True:
userInput=input("user# ")
time.sleep(0.5)
print("bot# ",respond(userInput))
@carlitoselmago I copied and pasted your code into a file named "chatbot.py" with model.npz in a folder named "saved". chatbot.py and "main.py" are in the same folder. When I run your code, I get this error:
C:\Users\tjpet\Downloads\seq2seq-chatbot-master\seq2seq-chatbot-master>py chatbot.py
Traceback (most recent call last):
File "chatbot.py", line 8, in <module>
tl.files.assign_weights(load_weights, model_)
NameError: name 'model_' is not defined
@Radioactivebun0 that because there's some problem importing main.py file. try to add an empty file called
__init__.py
in the folder where both main.py and chatbot.py are located.
@carlitoselmago I ran into the same error and I have created a __init__.py
but I am still falling into this error.
I figured it out!
I figured was that model_
and inference()
is defined in main.py
, but that only when __name__ == "__main__"
so it did not exist when I ran my file e.g chatbot.py
so I took the following outside the if __name__ == "__main__":
; data pre-processing, parameters, and other variables including the inference function.
I am not sure if this harms any of the code in main.py
though.
I don't need discord bot code I just want the method for using Your script I have knowledge in other languages programing