Commit 1020d0be authored by Manoj Kumar's avatar Manoj Kumar

check amashi work

parent c7b0b64d
import shutil
from flask import send_file
from reveng.processInput import checkCommon, processInput
from flask import Flask, render_template, request, redirect
from flask import flash,Flask, render_template, request, redirect
import json
import sys
import os
......@@ -42,12 +42,21 @@ def about():
return render_template('about.html')
import requests
# route to display GIF image to the user
@app.route('/tts/response/', methods=['POST'])
def response():
clearoutputfolder()
message = request.get_json()
responseGIF = processInput(message['message'])
URL = 'http://localhost:3000/tts/upload'
PARAMS = {
"files":{
"file":responseGIF
}
}
requests.post(URL,PARAMS)
return send_file(responseGIF, mimetype='image/gif')
......@@ -64,6 +73,54 @@ def clearoutputfolder():
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e))
from werkzeug.utils import secure_filename
## upload image
@app.route('/tts/upload', methods=['POST'])
def upload_image():
###
# This method is used upload the selected file to the exact folder
# after checking whether the extensions are matched.
# @return redirect to upload.html
###
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('No image selected for uploading')
return redirect(request.url)
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(main.config['UPLOAD_FOLDER'], filename))
flash('Image successfully uploaded and displayed')
return render_template('upload.html', filename=filename)
else:
flash('Allowed image types are -> png, jpg, jpeg, gif')
return redirect(request.url)
@app.route('/tts/display/<filename>')
def display_image(filename):
###
# This method is used display the uploaded file back to the user
# @return display the file in the interface
###
return redirect(url_for('static', filename='uploads/' + filename), code=301)
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
def allowed_file(filename):
###
# This method is used check the extension of selected file
# @return the extension to check whether it is allowed
###
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
# route to redirect Sign Translation page
@app.route('/tts')
......
......@@ -127,7 +127,8 @@ try:
score = round(100*output_dict['detection_scores'][0])
#send the request to translation component here
###
# I will be sending a POST request to u. a hand picture
# I will be sending a POST request to u. a hand picture
print(category_index)
if score > 80:
#print(image_np_expanded.shape)
img = Image.fromarray(temp_image)
......
......@@ -21,6 +21,7 @@ PATH = os.path.dirname(os.path.abspath(__file__))
gifName = ''.join(random.choices(string.ascii_uppercase +
string.digits, k=15))
STATIC_PATH = os.getcwd() + '\\static'
def generateGIF(images):
......@@ -30,7 +31,7 @@ def generateGIF(images):
# @return the generated GIF path
###
gifPath = os.path.join(PATH + "\\output\\" + gifName + '.gif')
gifPath = os.path.join(STATIC_PATH + "\\output\\" + gifName + '.gif')
imageio.mimwrite(gifPath, images, duration=0.5)
print(gifPath)
return gifPath
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment