Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
6e9572f5
Commit
6e9572f5
authored
Jun 18, 2021
by
Bogdan Mihai (ARTICONF student)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated funct for prediction
parent
fbc26ebf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
federated_algorithm.py
...ice/app/processing/text_processing/federated_algorithm.py
+6
-2
main_proc.py
...-microservice/app/processing/text_processing/main_proc.py
+1
-1
users.py
...n-hub/federated-learning-microservice/app/routes/users.py
+12
-9
No files found.
src/participation-hub/federated-learning-microservice/app/processing/text_processing/federated_algorithm.py
View file @
6e9572f5
...
@@ -97,8 +97,12 @@ def load_latest_state():
...
@@ -97,8 +97,12 @@ def load_latest_state():
return
restored_state
[
0
]
return
restored_state
[
0
]
def
make_prediction
(
input_prediction_data
):
def
make_prediction
(
input_prediction_data
):
try
:
with
open
(
"processing/"
+
globals
.
USE_CASE
+
"/last_model"
,
'rb'
)
as
f
:
with
open
(
"processing/"
+
globals
.
USE_CASE
+
"/last_model"
,
'rb'
)
as
f
:
state
=
pickle
.
load
(
f
)
state
=
pickle
.
load
(
f
)
except
Exception
as
e
:
print
(
e
)
return
None
model_for_inference
=
get_simple_LSTM_model
()
model_for_inference
=
get_simple_LSTM_model
()
state
.
model
.
assign_weights_to
(
model_for_inference
)
state
.
model
.
assign_weights_to
(
model_for_inference
)
...
...
src/participation-hub/federated-learning-microservice/app/processing/text_processing/main_proc.py
View file @
6e9572f5
...
@@ -68,4 +68,4 @@ def start_prediction(use_case, developer_id:int = -1):
...
@@ -68,4 +68,4 @@ def start_prediction(use_case, developer_id:int = -1):
#start_processing("text_processing")
#start_processing("text_processing")
start_prediction
(
"text_processing"
)
#start_prediction("text_processing")
\ No newline at end of file
\ No newline at end of file
src/participation-hub/federated-learning-microservice/app/routes/users.py
View file @
6e9572f5
from
flask
import
Response
,
request
from
flask
import
Response
,
request
import
sys
def
check_article
(
use_case
:
str
):
def
check_article
(
use_case
:
str
):
#body = request.STRING
#body = request.STRING
#TODO Working on it
use_case_path
=
'processing/'
+
use_case
+
'/'
#FOR USE_CASE {use_case}
sys
.
path
.
append
(
use_case_path
)
import
main_proc
#insert body into the trained model
result
=
main_proc
.
start_prediction
(
use_case
)
if
result
==
None
:
return
Response
(
status
=
404
,
response
=
"Server doesn't have a trained model. Training of the model should be finished before attempting a prediction."
)
return
Response
(
status
=
200
,
response
=
result
)
#get the result
#check_article("text_processing")
result
=
None
#bool True/False
\ No newline at end of file
return
Response
(
status
=
400
,
response
=
str
(
result
))
\ 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