Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dog Breed Identification #1107

Merged
merged 8 commits into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ImguploadConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ImgUpload'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import forms
class ImageUploadForm(forms.Form):
image=forms.ImageField()




Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions ImageProcessingScripts/Dog-Breed-Identification/ImgUpload/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.conf.urls import url
from django.contrib import admin
from django.urls import path
from django.urls.conf import include
from . import views

urlpatterns = [

url(r'^$', views.home, name='home'),
url(r'imageprocess', views.imageprocess , name='imageprocess')
]
46 changes: 46 additions & 0 deletions ImageProcessingScripts/Dog-Breed-Identification/ImgUpload/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from numpy.lib.function_base import append
from myWebApp.ImgUpload.form import ImageUploadForm
from django import forms
from django.shortcuts import render
from .form import ImageUploadForm

from keras.applications.resnet import ResNet50
from keras.preprocessing import image
from keras.applications.resnet import preprocess_input, decode_predictions
import numpy as np

def home(request):
return render(request,'home.html')

def imageprocess(request):
form=ImageUploadForm(request.POST, request.FILES )
if form.is_valid():
handle_uploaded_file(request.FILES['image'])
model= ResNet50(weights='imagenet')
img_path = 'img.jpg'
imge=image.load_img(img_path, target_size=(224,224))
x=image.img_to_array(imge)
x=np.expand_dims(x,axis=0)
x=preprocess_input(x)
preds=model.predict(x)
print('Pridicted',decode_predictions(preds,top=3)[0])

html=decode_predictions(preds,top=3,)[0]

res=[]
for e in html:
res.append((e[1],np.round(e[2]*100,2)))
return render(request,'result.html' , {'res':res})







def handle_uploaded_file(f):
with open('img.jpg','wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)

# Create your views here.
113 changes: 113 additions & 0 deletions ImageProcessingScripts/Dog-Breed-Identification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# ML-Based-Dog-Breed-Identifier

## Aim
To identify the breed of Dog

## Purpose
This is a Django Based Web Site To Identify the Breed of which your DOG belogs All You Need To Do is to Follow These Steps

## Workflow of the Project
From the Home user can find the tab to upload the Image and on result can be viewed on the result page.

## you need to install following libraries to run this python program in cmd
```

pip install tensorflow
pip install keras
pip install django
pip install numpy

```
## Compilation Steps

#### Step 1: Forking the repository :

To work on this project, you will first need to make your copy of the repository. To do this, you should fork the repository and then clone it so that you have a local working copy.

Get your own Fork/Copy of repository by clicking `Fork` button right upper corner.<br><br>

#### Step 2: Clone the Forked Repository

After the repository is forked, you can now clone it so that you have a local working copy of the codebase.

To make your local copy of the repository follow the steps:
- Open the Command Prompt
- Type this command:

```bash
$ git clone https://github.com/<your-github-username>/ML-Based-Dog-Breed-Identifier
```


#### Step 3: Creating a new branch (IMP)
This is one of the very important step that you should follow to contribute. A branch helps to manage the workflow, isolate your code and does not creates a mess. To create a new branch:

```bash
$ git branch <name_of_branch>
$ git checkout -b <name_of_branch>
```

Keep your cloned repo upto date by pulling from upstream (this will also avoid any merge conflicts while committing new changes)
```bash
git pull origin main
```

#### Step 4: Setting up Project

##### For Django:
**1. Create a Virtual Environment**

- *On macOS and Linux:*
```bash
python3 -m venv env
```
- *Windows*
```bash
py -m venv env
````

**2. Activate the Virtual Environment**
- *On Windows*
```bash
.\env\Scripts\activate
```
- *On macOS and Linux:*
```bash
source env/bin/activate
```

**4. Make Migrations**

```bash
python manage.py makemigrations
python manage.py migrate
```
**5. Run Server**

```bash
python manage.py runserver
```


**5.** Go to ` http://127.0.0.1:8000/` and enjoy the application



## Outputs

### Home Page
<img src="https://github.com/Knighthawk-Leo/ML-Based-Dog-Breed-Identifier/blob/main/Images/home.png">

### Result Page
<img src="https://github.com/Knighthawk-Leo/ML-Based-Dog-Breed-Identifier/blob/main/Images/Result.png">

## Author

<a href='https://github.com/Knighthawk-Leo'>Sanskar Dwivedi</a>

## Conclusion
Identified the Dog's Breed and results are significantly great .

##
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/built-by-developers.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)

Empty file.
22 changes: 22 additions & 0 deletions ImageProcessingScripts/Dog-Breed-Identification/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myWebApp.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ImguploadConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ImgUpload'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import forms
class ImageUploadForm(forms.Form):
image=forms.ImageField()




Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# from django.conf.urls import url
from django.contrib import admin
from django.urls import include ,re_path
from django.urls.conf import include
from . import views

urlpatterns = [

re_path(r'^$', views.home, name='home'),
re_path(r'imageprocess', views.imageprocess , name='imageprocess')
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from myWebApp.ImgUpload.form import ImageUploadForm
from django import forms
from django.shortcuts import render
from .form import ImageUploadForm

def home(request):
return render(request,'home.html')

def imageprocess(request):
form=ImageUploadForm(request.POST, request.FILES )
if form.is_valid():
handel_uploaded_file(request.FILES['image'])
return render(request,'result.html')

def handel_uploaded_file(f):
with open('img.jpg','wb+')as destination:
for chunk in f.chunks():
destination.write(chunk)

# Create your views here.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions ImageProcessingScripts/Dog-Breed-Identification/myWebApp/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for myWebApp project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myWebApp.settings')

application = get_asgi_application()
Loading