pnavin commited on
Commit
484f1ce
1 Parent(s): 9ace5a7

Upload 14 files

Browse files
Human Age Prediction/app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template
2
+ import numpy as np
3
+ import tensorflow as tf
4
+ from tensorflow.keras.preprocessing import image
5
+ import os
6
+ import json
7
+
8
+ app = Flask(__name__, static_folder='static')
9
+
10
+
11
+ @app.route('/')
12
+ def index():
13
+ return render_template('index.html')
14
+
15
+
16
+ @app.route('/predictdata', methods=['GET', 'POST'])
17
+ def predict_datapoint():
18
+ if request.method == 'GET':
19
+ print("Accepting Input")
20
+ return render_template('home.html', results="Submit")
21
+ else:
22
+ print("Started with Post")
23
+ model_path = os.path.join("artifacts", "model.h5")
24
+ model = tf.keras.models.load_model(model_path)
25
+ upload_file = request.files['image']
26
+ temp_filename = 'temp.png'
27
+ upload_file.save(temp_filename)
28
+ img = os.path.join(os.getcwd(), temp_filename)
29
+ img = image.img_to_array(tf.image.resize(image.load_img(img), [224, 224])) / 255
30
+ img = np.expand_dims(img, axis=0)
31
+
32
+ results = model.predict(img)
33
+ print("after Prediction")
34
+ results_json = json.dumps("Predicted Age = "+str(results[0][0].tolist())) # Convert the results to JSON format
35
+
36
+ os.remove(temp_filename) # Remove the temporary file
37
+
38
+ return results_json
39
+
40
+
41
+ if __name__ == "__main__":
42
+ app.run(host="0.0.0.0", debug=True)
Human Age Prediction/artifacts/model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57cdd55998f71ca5ffecf0594e4bf1e92631917be494a52aff5af9e7ac7c439d
3
+ size 130227256
Human Age Prediction/artifacts/model.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1b8865d31f50c973496f5e24ed36b1305d9245ec276a1814e618a4419a546d1
3
+ size 35543390
Human Age Prediction/artifacts/model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63dc5eae8fed9cc1fc118b15e2b6d6ec45e7450cda6c6ec6a467d893ffa46751
3
+ size 2589350
Human Age Prediction/mlproject.egg-info/PKG-INFO ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: mlproject
3
+ Version: 0.0.1
4
+ Author: Navin
5
+ Author-email: patwarinavin9@gmail.com
Human Age Prediction/mlproject.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ setup.py
2
+ mlproject.egg-info/PKG-INFO
3
+ mlproject.egg-info/SOURCES.txt
4
+ mlproject.egg-info/dependency_links.txt
5
+ mlproject.egg-info/requires.txt
6
+ mlproject.egg-info/top_level.txt
Human Age Prediction/mlproject.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Human Age Prediction/mlproject.egg-info/requires.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ pandas==2.0.1
2
+ numpy==1.24.3
3
+ flask==2.3.2
4
+ tensorflow
Human Age Prediction/mlproject.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
Human Age Prediction/requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas==2.0.1
2
+ numpy==1.24.3
3
+ flask==2.3.2
4
+ tensorflow
5
+ -e .
Human Age Prediction/setup.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import find_packages,setup
2
+ from typing import List
3
+
4
+ HYPEN_E_DOT='-e .'
5
+ def get_requirements(file_path:str)->List[str]:
6
+ '''
7
+ this function will return the list of requirements
8
+ '''
9
+ requirements=[]
10
+ with open(file_path) as file_obj:
11
+ requirements=file_obj.readlines()
12
+ requirements=[req.replace("\n","") for req in requirements]
13
+
14
+ if HYPEN_E_DOT in requirements:
15
+ requirements.remove(HYPEN_E_DOT)
16
+
17
+ return requirements
18
+
19
+ setup(
20
+ name='mlproject',
21
+ version='0.0.1',
22
+ author='Navin',
23
+ author_email='patwarinavin9@gmail.com',
24
+ packages=find_packages(),
25
+ install_requires=get_requirements('requirements.txt')
26
+
27
+ )
Human Age Prediction/temp.jpg ADDED
Human Age Prediction/templates/home.html ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Image Input Example</title>
5
+ <style>
6
+ #preview {
7
+ max-width: 300px;
8
+ max-height: 300px;
9
+ display: none; /* Hide the preview image initially */
10
+ }
11
+ </style>
12
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
13
+ <script>
14
+ $(document).ready(function() {
15
+ $("#upload-form").submit(function(event) {
16
+ event.preventDefault(); // Prevent the default form submission
17
+ var formData = new FormData(this);
18
+
19
+ $.ajax({
20
+ url: "{{ url_for('predict_datapoint') }}",
21
+ type: "POST",
22
+ data: formData,
23
+ processData: false,
24
+ contentType: false,
25
+ success: function(response) {
26
+ // Update the results field with the response
27
+ $("#results").text(response);
28
+ }
29
+ });
30
+ });
31
+ });
32
+
33
+ function showPreview(event) {
34
+ var input = event.target;
35
+ var reader = new FileReader();
36
+ var preview = document.getElementById('preview');
37
+
38
+ reader.onload = function() {
39
+ preview.src = reader.result;
40
+ preview.style.display = 'block'; // Show the preview image
41
+ };
42
+
43
+ if (input.files && input.files[0]) {
44
+ reader.readAsDataURL(input.files[0]);
45
+ } else {
46
+ preview.src = '#';
47
+ preview.style.display = 'none'; // Hide the preview image
48
+ }
49
+ }
50
+ </script>
51
+ </head>
52
+ <body>
53
+ <h1>Image Input</h1>
54
+
55
+ <form id="upload-form" enctype="multipart/form-data">
56
+ <input type="file" name="image" required onchange="showPreview(event)">
57
+ <br>
58
+ <img id="preview" src="#" alt="Image Preview">
59
+ <br>
60
+ <button class="btn btn--radius-2 btn--blue" type="submit">Submit</button>
61
+ </form>
62
+
63
+ <div id="results"></div>
64
+
65
+ </body>
66
+ </html>
Human Age Prediction/templates/index.html ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
2
+ <h1 id="abc">Welcome to the home page</h1>