Skip to content
Snippets Groups Projects
Commit b9a877e4 authored by h4-rahman's avatar h4-rahman
Browse files

Removed exposed ports from Tensorflow container so it cannot be accessed outside docker network.

Token Count decreases by 1 when using model.
parent dd3dddc8
No related branches found
No related tags found
1 merge request!34Removing of exposed ports for tensorflow container
......@@ -41,8 +41,6 @@ services:
tensorflow_serving:
image: tensorflow/serving
ports:
- "8501:8501"
volumes:
- ./models:/models
environment:
......
......@@ -262,6 +262,17 @@ def generate_pdf(request):
# Running the audio file through the model
class InstrumentDetectionView(APIView):
def post(self, request):
# Get the user's token count
user_token_count = UserTokenCount.objects.get(user=request.user)
# Check if the user has more than one token
if user_token_count.token_count < 1:
return Response({'error': 'Insufficient tokens'}, status=status.HTTP_403_FORBIDDEN)
# Decrease the user's token count by one
user_token_count.token_count -= 1
user_token_count.save()
serializer = InstrumentDetectionSerializer(data=request.data)
if serializer.is_valid():
audio_file = serializer.validated_data['audio_file']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment