Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xtnctx authored Dec 2, 2022
1 parent 5e02833 commit 1b857b3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bfrbsysAPI/apis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def post(self, request, format=None):
named_model = request.data.get('model_name')
file = request.data.get("file")
fileName = request.data.get("fileName")

if named_model == '':
named_model = 'NO_NAME_MODEL'

df = pd.read_csv(file)

Expand Down Expand Up @@ -129,6 +132,10 @@ def post(self, request, format=None):
history = model.fit(inputs_train, outputs_train, epochs=N_EPOCH, batch_size=1,
validation_data=(inputs_validate, outputs_validate))






# print("Evaluate on test data")
# results = model.evaluate(inputs_test, outputs_test)
Expand All @@ -152,13 +159,16 @@ def post(self, request, format=None):
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_model = converter.convert()

owner_file = str(named_model).replace(" ", "_") + f'--{request.user.username}'
data = {
'owner': request.user.id,
'model_name': named_model,
'file': ContentFile(bytes(hex_to_c_array(tflite_model), 'utf-8'), name=named_model+'.h')
'file': ContentFile(bytes(hex_to_c_array(tflite_model), 'utf-8'),
name=owner_file + '.h'
),
'callback_file': ContentFile(bytes(callback_string(history), 'utf-8'),
name=owner_file + '.csv'),
}



serializer = TrainedModelSerializer(data=data)
if serializer.is_valid():
Expand Down

0 comments on commit 1b857b3

Please sign in to comment.