Skip to content

Commit

Permalink
ImageDetectionWorking
Browse files Browse the repository at this point in the history
  • Loading branch information
igoorsimoess committed Dec 21, 2022
1 parent 15fd439 commit 0aad52b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
Binary file modified back-end/back-end/src/CV/CV/__pycache__/urls.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion back-end/back-end/src/CV/CV/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'teste', views.ImageDetectionViewSet, basename='detection')
router.register(r'ImageDetection', views.ImageDetectionViewSet, basename='ImageDetection')

urlpatterns = [
path("admin/", admin.site.urls),
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion back-end/back-end/src/CV/ImageDetection/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class Meta:
class ImageDetectionSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = ImageDetection
fields = ["created_at", "image", "model_evaluation", "model_evaluation_dict"]
fields = ["created _at", "image", "model_evaluation", "model_evaluation_dict"]
11 changes: 7 additions & 4 deletions back-end/back-end/src/CV/ImageDetection/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from ImageDetection.serializers import UserSerializer, GroupSerializer, ImageDetectionSerializer
import torch
from rest_framework.decorators import action
# queryset = Group.objects.all().order_by()
from rest_framework.decorators import action

# Create your views here.
import os

from django.http import JsonResponse
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
Expand All @@ -33,7 +33,10 @@ class ImageDetectionViewSet(viewsets.ModelViewSet):

@action(methods=["GET", "POST"], url_path='evaluate', detail=False)
def evaluate(self, request, model=model):
image = request.POST.get("image", None)
image = request.POST.get("image", "../../../../static/imagem.png" )
image = request.GET.get("image", "../../../../static/imagem.png" )
# image = request.GET.get("")
model_evaluation = model(image)
model_evaluation_dict = model_evaluation.pandas().xyxy[0].to_dict(orient="records")
return model_evaluation_dict
return JsonResponse(model_evaluation_dict, safe=False)

0 comments on commit 0aad52b

Please sign in to comment.