This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Inference list</tile> | |
</head> | |
<body> | |
{% for inference_obj in inference_objects %} | |
<div> | |
<img src='{{inference_obj.image.url}}' /> | |
<h3>Prediction => {{inference_obj.prediction}}</h3> | |
<hr/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import Inference | |
# Register your models here. | |
admin.site.register(Inference) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from .views import inference_detail_view,inference_list_view,inference_create_view,inference_update_view,inference_delete_view | |
urlpatterns = [ | |
path('',inference_list_view) | |
path('inference/<int:pk>/',inference_detail_view) | |
path('inference/create/',inference_create_view) | |
path('inference/<int:pk>/update/',inference_update_view) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from .models import Inference | |
from .forms import InferenceForm | |
def inference_detail_view(request,id): | |
product_obj = Inference.objects.get(id=id) | |
context = {'inference_obj':product_obj} | |
return render(request,'inference_detail.html',context) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from .models import Inference | |
from keras.preprocessing import image | |
from keras.models import model_from_json | |
import numpy as np | |
class InferenceForm(forms.ModelForm): | |
class Meta : | |
model = Inference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Inference(models.Model): | |
image = models.ImageField(null=True) | |
prediction = models.CharFiedl(max_length=255) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = [ | |
# ... | |
'inference' , | |
] | |
# configure celery and redis | |
BROKER_URL = 'redis://localhost:6379' | |
CELERY_RESULT_BACKEND = 'redis://' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from celery import Celery | |
from django.conf import settings | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyApp.settings') | |
app = Celery('MyApp') | |
app.config_from_object('django.conf:settings') | |
app.autodiscover_tasks(settings.INSTALLED_APPS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.urls import path,include | |
from django.conf.urls.static import static | |
from django.conf import settings | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('api/',include('inference.urls')), | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from MyApp.celery import app | |
import numpy as np | |
from keras.preprocessing import image | |
from keras.models import model_from_json | |
from .models import Inference | |
@app.task(bind=True) | |
def run_inference(self, inference_id): |