Skip to content

Instantly share code, notes, and snippets.

@aballah-chamakh
Last active November 17, 2019 05:36
Show Gist options
  • Select an option

  • Save aballah-chamakh/ebefaa691af0d9890a094d4c8d8d3280 to your computer and use it in GitHub Desktop.

Select an option

Save aballah-chamakh/ebefaa691af0d9890a094d4c8d8d3280 to your computer and use it in GitHub Desktop.
from rest_framework import serializers
from .models import Inference
from .tasks import run_inference
class InferenceSerializers(serializers.ModelSerializers):
class Meta :
model = Inference
fields = ('name','result')
def create(self,validated_data):
name = validated_data.get('name')
image = validated_data.get('image')
inference_obj = Inference.objects.create(name=name,image=image) # or simply Inference.objects.create(**validated_data)
run_infernece.delay(inference_obj.id) # run inference async
return inference_obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment