-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Image Training Endpoint to Django #1011
Conversation
took a stab at this. a couple questions i had was.
With transition to django, is the path for data uploads still gonna be in backend/data_uploads?
If everything looks good here (no red flags in code), i can begin testing with our default datsets to make sure our trainspace flow is working as intended. |
for image data uploads, please dont use backend/ dir. |
sure, then what directory do i use? I dont see a similar directory in /training |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added more comments @codingwithsurya
i think u can test the endpoint out @codingwithsurya |
should be clarified |
yea looks good. i just commited what we talked about. and i'll test on colab as well soon when i get a chance. |
) | ||
for epoch_result in trainer: | ||
print(epoch_result) | ||
print(trainer.labels_last_epoch, trainer.y_pred_last_epoch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these print statements necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw this in the original tabular.py as well. if they're not necessary, i can remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farisdurrani @karkir0003 any clarification on what to do here. Are all the print statements necessary in grand scheme of things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we resolve this @codingwithsurya
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added minor comments on static typing python
7f9ab66
to
b3e82b9
Compare
addressed all these |
9ab1b12
to
5cbbaf0
Compare
TO-DO: find viable nnSequential PyTorch MNIST Architecture for testing |
5fadf7f
to
6a35554
Compare
TODO: Cross-Entropy Loss not computing correctly. Figure out correct param for FLATTEN in current architecture. Otherwise, we can make our own |
backend/tests/test_model.py
Outdated
for module in my_model.model.modules() | ||
if not isinstance(module, nn.Sequential) | ||
] == input_list | ||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "pytest" could not be resolved (reportMissingImports)
backend/tests/test_model.py
Outdated
@@ -21,0 +1,20 @@ | |||
import pytest | |||
import torch.nn as nn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "torch.nn" could not be resolved (reportMissingImports)
backend/tests/test_model_parser.py
Outdated
) | ||
def test_parse_user_architecture(user_model, expected): | ||
assert [i == j for i, j in zip(parse_deep_user_architecture(user_model), expected)] | ||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "pytest" could not be resolved (reportMissingImports)
backend/tests/test_model_parser.py
Outdated
@@ -30,0 +1,29 @@ | |||
import pytest | |||
import torch.nn as nn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "torch.nn" could not be resolved (reportMissingImports)
training/tests/test_loss_function.py
Outdated
loss_function_name = "BCELOSS" | ||
computed_loss = compute_loss(loss_function_name, output, labels) | ||
assert pytest.approx(expected_number) == computed_loss | ||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "pytest" could not be resolved (reportMissingImports)
training/training/core/dl_model.py
Outdated
@@ -1,8 +1,11 @@ | |||
from typing import Any, Callable | |||
from ninja import Schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "ninja" could not be resolved (reportMissingImports)
for epoch_result in trainer: | ||
print(epoch_result) | ||
from typing import Literal, Optional | ||
from django.http import HttpRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "django.http" could not be resolved (reportMissingImports)
@@ -66,0 +1,65 @@ | |||
from typing import Literal, Optional | |||
from django.http import HttpRequest | |||
from ninja import Router, Schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "ninja" could not be resolved (reportMissingImports)
from training.core.criterion import getCriterionHandler | ||
from training.core.dataset import SklearnDatasetCreator | ||
from training.core.dl_model import DLModel | ||
from torch.utils.data import DataLoader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Import "torch.utils.data" could not be resolved (reportMissingImports)
drop_last=True, | ||
) | ||
|
||
model = DLModel.fromLayerParamsList(tabularParams.user_arch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [pyright] reported by reviewdog 🐶
Argument of type "list[LayerParams]" cannot be assigned to parameter "layer_params_list" of type "list[LayerParams]" in function "fromLayerParamsList"
"builtins.list" is incompatible with "builtins.list"
Type parameter "_T@list" is invariant, but "training.training.routes.tabular.schemas.LayerParams" is not the same as "training.training.routes.image.schemas.LayerParams"
Consider switching from "list" to "Sequence" which is covariant (reportGeneralTypeIssues)
07a70f3
to
dbc97d1
Compare
Update: MNIST dataset testing works! TODO: Train/test transforms as parameter to endpoint. CIFAR10 Testing. |
eab06b8
to
07a70f3
Compare
36501e3
to
3af1d65
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Migrate Image Training Endpoint to Django
Github Issue Number Here: Feature#993
What user problem are we solving?
With the ongoing migration from Flask Blueprint to Django for better scalability and maintainability, we need to ensure that the training endpoints for image datasets continue to function as expected. Users need a reliable endpoint to submit image training requests and this migration aims to improve the overall infrastructure.
What solution does this PR provide?
This PR introduces the /image route within the Django framework, replacing the old Flask Blueprint route. The new route handles image training requests, particularly focusing on classification tasks as regression is not supported. The structure of this endpoint is mirrored from the specified reference, with adjustments made to fit the Django framework. The old image train code served as inspiration for ensuring that the necessary features and behaviors are retained.
Testing Methodology
Testing yet to be done but to verify the functionality and integrity of the new /image route, but when testing begins, we can submit training requests using torch built-in datasets (MNIST, FashionMNIST) to ensure that models train as expected and the endpoint returns accurate results.
Also use postman for testing .
Any other considerations