Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Codigos_AEG
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ADITYA ANIL JAIN
Codigos_AEG
Commits
317184cd
Commit
317184cd
authored
Oct 29, 2019
by
shreyansh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shifted server from node->starlette
parent
16051a1c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
12 deletions
+79
-12
Softlab.yml
Softlab.yml
+12
-0
main.py
main.py
+56
-0
oldNodeApp/gAuth.js
oldNodeApp/gAuth.js
+0
-0
oldNodeApp/main.js
oldNodeApp/main.js
+0
-0
oldNodeApp/package.json
oldNodeApp/package.json
+0
-0
oldNodeApp/plagarismCheck.js
oldNodeApp/plagarismCheck.js
+0
-0
prediction.py
prediction.py
+11
-12
No files found.
Softlab.yml
View file @
317184cd
...
...
@@ -26,13 +26,18 @@ dependencies:
-
boto==2.49.0
-
boto3==1.10.4
-
botocore==1.13.4
-
cachetools==3.1.1
-
chardet==3.0.4
-
click==7.0
-
docutils==0.15.2
-
gast==0.2.2
-
gensim==3.8.1
-
google-auth==1.6.3
-
google-pasta==0.1.7
-
grpcio==1.24.3
-
h11==0.8.1
-
h5py==2.10.0
-
httptools==0.0.13
-
idna==2.8
-
jmespath==0.9.4
-
keras-applications==1.0.8
...
...
@@ -42,17 +47,24 @@ dependencies:
-
numpy==1.17.3
-
opt-einsum==3.1.0
-
protobuf==3.10.0
-
pyasn1==0.4.7
-
pyasn1-modules==0.2.7
-
python-dateutil==2.8.0
-
requests==2.22.0
-
rsa==4.0
-
s3transfer==0.2.1
-
scipy==1.3.1
-
six==1.12.0
-
smart-open==1.8.4
-
starlette==0.12.10
-
tensorboard==2.0.0
-
tensorflow==2.0.0
-
tensorflow-estimator==2.0.1
-
termcolor==1.1.0
-
urllib3==1.25.6
-
uvicorn==0.9.1
-
uvloop==0.13.0
-
websockets==8.0.2
-
werkzeug==0.16.0
-
wrapt==1.11.2
prefix
:
/home/shreyansh/.conda/envs/Softlab
...
...
main.py
0 → 100644
View file @
317184cd
from
google.oauth2
import
service_account
from
google.auth.transport.requests
import
AuthorizedSession
from
starlette.applications
import
Starlette
from
starlette.responses
import
JSONResponse
,
PlainTextResponse
from
prediction
import
predict
import
uvicorn
import
json
scopes
=
[
"https://www.googleapis.com/auth/userinfo.email"
,
"https://www.googleapis.com/auth/firebase.database"
]
app
=
Starlette
(
debug
=
True
)
credentials
=
service_account
.
Credentials
.
from_service_account_file
(
"./serviceKey.json"
,
scopes
=
scopes
)
authed_session
=
AuthorizedSession
(
credentials
)
@
app
.
route
(
'/'
)
async
def
homepage
(
request
):
return
JSONResponse
({
'hello'
:
'world'
})
@
app
.
route
(
'/{prompt}'
)
async
def
getEssay
(
request
):
prompt
=
request
.
path_params
[
'prompt'
]
response
=
authed_session
.
get
(
"https://softlab-ba722.firebaseio.com/"
+
prompt
+
".json"
)
return
JSONResponse
(
response
.
json
())
# app.add_route('/evaluate', predict, methods=["POST"])
@
app
.
route
(
'/evaluate'
,
methods
=
[
"POST"
])
async
def
evaluate
(
request
):
body
=
await
request
.
json
()
score
=
predict
(
body
[
'essay'
])
return
PlainTextResponse
(
score
)
@
app
.
route
(
'/contribute'
,
methods
=
[
"POST"
])
async
def
evaluate
(
request
):
body
=
await
request
.
json
()
score
,
essay
,
prompt
=
body
[
'score'
],
body
[
'essay'
],
body
[
'prompt'
]
json
=
{
"essay"
:
essay
,
"score"
:
score
}
message
=
"Success, Thanks for your envaluable contribution!"
response
=
authed_session
.
post
(
"https://softlab-ba722.firebaseio.com/"
+
prompt
+
"/.json"
,
None
,
json
)
print
(
response
)
if
response
.
status_code
!=
200
:
message
=
"Oops some error occured please try after some time."
return
PlainTextResponse
(
message
)
if
__name__
==
'__main__'
:
uvicorn
.
run
(
app
,
host
=
'0.0.0.0'
,
port
=
8000
)
\ No newline at end of file
gAuth.js
→
oldNodeApp/
gAuth.js
View file @
317184cd
File moved
main.js
→
oldNodeApp/
main.js
View file @
317184cd
File moved
package.json
→
oldNodeApp/
package.json
View file @
317184cd
File moved
plagarismCheck.js
→
oldNodeApp/
plagarismCheck.js
View file @
317184cd
File moved
prediction.py
View file @
317184cd
...
...
@@ -40,18 +40,17 @@ def getAvgFeatureVecs(essays, model, num_features):
counter
=
counter
+
1
return
essayFeatureVecs
def
predict
(
essay
):
model
=
KeyedVectors
.
load_word2vec_format
(
'models/word2vecmodel.bin'
,
binary
=
True
)
essay_tokens
=
[]
model
=
KeyedVectors
.
load_word2vec_format
(
'models/word2vecmodel.bin'
,
binary
=
True
)
essay_tokens
=
[]
essay
=
sys
.
argv
[
1
]
essay_tokens
.
append
(
tokenizeEssay
(
essay
))
testEssayVec
=
getAvgFeatureVecs
(
essay_tokens
,
model
,
300
)
essay_tokens
.
append
(
tokenizeEssay
(
essay
)
)
testEssayVec
=
getAvgFeatureVecs
(
essay_tokens
,
model
,
300
)
testEssayVec
=
np
.
array
(
testEssayVec
)
testEssayVec
=
np
.
reshape
(
testEssayVec
,(
testEssayVec
.
shape
[
0
],
1
,
testEssayVec
.
shape
[
1
])
)
testEssayVec
=
np
.
array
(
testEssayVec
)
testEssayVec
=
np
.
reshape
(
testEssayVec
,(
testEssayVec
.
shape
[
0
],
1
,
testEssayVec
.
shape
[
1
]))
evaluator
=
keras
.
models
.
load_model
(
'models/final_lstm.h5'
)
y_pred
=
evaluator
.
predict
(
testEssayVec
)
y_pred
=
np
.
around
(
y_pred
)
print
(
y_pred
.
reshape
(
-
1
)[
0
])
\ No newline at end of file
evaluator
=
keras
.
models
.
load_model
(
'models/final_lstm.h5'
)
y_pred
=
evaluator
.
predict
(
testEssayVec
)
y_pred
=
0
if
np
.
isnan
(
y_pred
[
0
][
0
])
else
np
.
around
(
y_pred
[
0
][
0
])
return
str
(
y_pred
)
\ No newline at end of file
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