Skip to content

Commit c5b6c88

Browse files
Merge pull request #1107 from Knighthawk-Leo/main
Dog Breed Identification
2 parents 2ccfa2e + 387d8db commit c5b6c88

File tree

128 files changed

+14630
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+14630
-0
lines changed

ImageProcessingScripts/Dog-Breed-Identification/ImgUpload/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ImguploadConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'ImgUpload'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django import forms
2+
class ImageUploadForm(forms.Form):
3+
image=forms.ImageField()
4+
5+
6+
7+

ImageProcessingScripts/Dog-Breed-Identification/ImgUpload/migrations/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.conf.urls import url
2+
from django.contrib import admin
3+
from django.urls import path
4+
from django.urls.conf import include
5+
from . import views
6+
7+
urlpatterns = [
8+
9+
url(r'^$', views.home, name='home'),
10+
url(r'imageprocess', views.imageprocess , name='imageprocess')
11+
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from numpy.lib.function_base import append
2+
from myWebApp.ImgUpload.form import ImageUploadForm
3+
from django import forms
4+
from django.shortcuts import render
5+
from .form import ImageUploadForm
6+
7+
from keras.applications.resnet import ResNet50
8+
from keras.preprocessing import image
9+
from keras.applications.resnet import preprocess_input, decode_predictions
10+
import numpy as np
11+
12+
def home(request):
13+
return render(request,'home.html')
14+
15+
def imageprocess(request):
16+
form=ImageUploadForm(request.POST, request.FILES )
17+
if form.is_valid():
18+
handle_uploaded_file(request.FILES['image'])
19+
model= ResNet50(weights='imagenet')
20+
img_path = 'img.jpg'
21+
imge=image.load_img(img_path, target_size=(224,224))
22+
x=image.img_to_array(imge)
23+
x=np.expand_dims(x,axis=0)
24+
x=preprocess_input(x)
25+
preds=model.predict(x)
26+
print('Pridicted',decode_predictions(preds,top=3)[0])
27+
28+
html=decode_predictions(preds,top=3,)[0]
29+
30+
res=[]
31+
for e in html:
32+
res.append((e[1],np.round(e[2]*100,2)))
33+
return render(request,'result.html' , {'res':res})
34+
35+
36+
37+
38+
39+
40+
41+
def handle_uploaded_file(f):
42+
with open('img.jpg','wb+') as destination:
43+
for chunk in f.chunks():
44+
destination.write(chunk)
45+
46+
# Create your views here.
Lines changed: 113 additions & 0 deletions

ImageProcessingScripts/Dog-Breed-Identification/db.sqlite3

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myWebApp.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

ImageProcessingScripts/Dog-Breed-Identification/myWebApp/ImgUpload/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ImguploadConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'ImgUpload'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django import forms
2+
class ImageUploadForm(forms.Form):
3+
image=forms.ImageField()
4+
5+
6+
7+

ImageProcessingScripts/Dog-Breed-Identification/myWebApp/ImgUpload/migrations/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# from django.conf.urls import url
2+
from django.contrib import admin
3+
from django.urls import include ,re_path
4+
from django.urls.conf import include
5+
from . import views
6+
7+
urlpatterns = [
8+
9+
re_path(r'^$', views.home, name='home'),
10+
re_path(r'imageprocess', views.imageprocess , name='imageprocess')
11+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from myWebApp.ImgUpload.form import ImageUploadForm
2+
from django import forms
3+
from django.shortcuts import render
4+
from .form import ImageUploadForm
5+
6+
def home(request):
7+
return render(request,'home.html')
8+
9+
def imageprocess(request):
10+
form=ImageUploadForm(request.POST, request.FILES )
11+
if form.is_valid():
12+
handel_uploaded_file(request.FILES['image'])
13+
return render(request,'result.html')
14+
15+
def handel_uploaded_file(f):
16+
with open('img.jpg','wb+')as destination:
17+
for chunk in f.chunks():
18+
destination.write(chunk)
19+
20+
# Create your views here.

ImageProcessingScripts/Dog-Breed-Identification/myWebApp/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for myWebApp project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myWebApp.settings')
15+
16+
application = get_asgi_application()

0 commit comments

Comments
 (0)