Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-077
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-077
2020-077
Commits
1020d0be
Commit
1020d0be
authored
Jan 03, 2021
by
Manoj Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check amashi work
parent
c7b0b64d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
3 deletions
+62
-3
api.py
api.py
+58
-1
dataq/detect.py
dataq/detect.py
+2
-1
reveng/gifMaker.py
reveng/gifMaker.py
+2
-1
No files found.
api.py
View file @
1020d0be
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'
)
...
...
dataq/detect.py
View file @
1020d0be
...
...
@@ -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
)
...
...
reveng/gifMaker.py
View file @
1020d0be
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment