Skip to content

able to get reply from the train.py,but the response is not corresponding to the input that i type in ? #6

@akhilgentoo

Description

@akhilgentoo

have made changes to your server.py file

from flask import Flask, render_template, jsonify
from time import sleep
from flask import request
import sys
sys.path.append('/home/labs/Documents/Neural-Chatbot-master/src/utils')
sys.path.append('/home/labs/Documents/Neural-Chatbot-master/src/model')
from sampling import Sampler
from models import seq2seq, seq2seq_attention
import json

from config_utils import settings
app = Flask(name)

@app.route('/')
def index_page():
return render_template('index.html')

@app.route('/respond', methods=['POST'])
def respond():

sequence_length = settings.model.sequence_length
	vocabulary_size = settings.model.vocabulary_size
	hidden_size = settings.model.hidden_size
	print ('Creating model with configuration: {0}'.format(settings.model))

	model = seq2seq_attention(sequence_length, vocabulary_size, hidden_size)
	print ('Loading model weights from {0}'.format(settings.model.weights_path))
	model.load_weights('/home/infinitylabs/Documents/Neural-Chatbot-master/models/seq2seq_weights.h5')

	vocabulary_file = settings.data.vocabulary_path
	with open(vocabulary_file, 'r') as handle:
    	vocabulary = json.load(handle)

	sampler = Sampler(model, vocabulary, sequence_length)
question = request.form['message']
    response = sampler.respond(question, greedy=True)
    print (response)
    for t in (.7, .8, .9):
        response = sampler.respond(question, temperature=True)
        print (response)

	    	
return jsonify({ 'response': response })

if name == 'main':
app.run(port=8000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions