LDJA commited on
Commit
ba6b28a
Β·
1 Parent(s): ee3c19e
.DS_Store ADDED
Binary file (6.15 kB). View file
 
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:18.04
2
+
3
+ LABEL Version="1.0"
4
+
5
+ RUN apt-get update -y
6
+
7
+ RUN apt-get install -y python3-pip python3-dev build-essential
8
+
9
+ COPY ./app /app
10
+
11
+ EXPOSE 7860
12
+
13
+ WORKDIR /app
14
+
15
+ RUN pip3 install --no-cache-dir --upgrade pip
16
+
17
+ RUN pip3 install -r requirements.txt
18
+
19
+ ENV FLASK_APP main
20
+
21
+ ENTRYPOINT python3 main.py
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Iris3
3
- emoji: 🐨
4
- colorFrom: blue
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
1
  ---
2
+ title: Iris
3
+ emoji: πŸ”₯
4
+ colorFrom: pink
5
+ colorTo: red
6
  sdk: docker
7
  pinned: false
8
  license: mit
app/.DS_Store ADDED
Binary file (6.15 kB). View file
 
app/main.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ from flask import Flask, render_template, request
3
+
4
+
5
+ IRIS_TYPES = {
6
+ 0: 'setosa',
7
+ 1: 'versicolor',
8
+ 2: 'virginica'
9
+ }
10
+
11
+ app = Flask(__name__)
12
+
13
+
14
+ @app.route('/', methods=['GET'])
15
+ def iris_index():
16
+ return render_template('index.html')
17
+
18
+
19
+ @app.route('/predict/', methods=['POST'])
20
+ def result():
21
+ if request.method == 'POST':
22
+ sepal_length = request.form['inputSepalLength']
23
+ sepal_width = request.form['inputSepalWidth']
24
+ petal_length = request.form['inputPetalLength']
25
+ petal_width = request.form['inputPetalWidth']
26
+
27
+ data = [[sepal_length, sepal_width, petal_length, petal_width]]
28
+
29
+ model = pickle.load(open(f"model.sav", 'rb'))
30
+ pred = model.predict(data)[0]
31
+
32
+ return render_template('prediction.html', iris_type=IRIS_TYPES[pred])
33
+
34
+ if __name__ == '__main__':
35
+ app.debug = True
36
+ app.run(
37
+ host='0.0.0.0',
38
+ port=7860,
39
+ debug=True)
app/model.sav ADDED
Binary file (7.39 kB). View file
 
app/requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ scikit-learn==0.24.1
2
+ Flask
3
+ Jinja2
4
+ MarkupSafe
5
+ Werkzeug
6
+ pickle5
app/static/.DS_Store ADDED
Binary file (6.15 kB). View file
 
app/static/css/bootstrap.min.css ADDED
The diff for this file is too large to render. See raw diff
 
app/static/css/jumbotron-narrow.css ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Space out content a bit */
2
+ body {
3
+ padding-top: 20px;
4
+ padding-bottom: 20px;
5
+ }
6
+
7
+ a, a:hover, a:visited, a:link, a:active{
8
+ text-decoration: none;
9
+ }
10
+
11
+ /* Everything but the jumbotron gets side spacing for mobile first views */
12
+ .header,
13
+ .marketing,
14
+ .footer {
15
+ padding-right: 15px;
16
+ padding-left: 15px;
17
+ }
18
+
19
+ /* Custom page header */
20
+ .header {
21
+ padding-bottom: 20px;
22
+ border-bottom: 1px solid #e5e5e5;
23
+ }
24
+ /* Make the masthead heading the same height as the navigation */
25
+ .header h3 {
26
+ margin-top: 0;
27
+ margin-bottom: 0;
28
+ line-height: 40px;
29
+ }
30
+
31
+ /* Custom page footer */
32
+ .footer {
33
+ padding-top: 19px;
34
+ color: #777;
35
+ border-top: 1px solid #e5e5e5;
36
+ }
37
+
38
+ /* Customize container */
39
+ @media (min-width: 768px) {
40
+ .container {
41
+ max-width: 730px;
42
+ }
43
+ }
44
+ .container-narrow > hr {
45
+ margin: 30px 0;
46
+ }
47
+
48
+ /* Main marketing message and sign up button */
49
+ .jumbotron {
50
+ text-align: center;
51
+ border-bottom: 1px solid #e5e5e5;
52
+ }
53
+ .jumbotron .btn {
54
+ padding: 14px 24px;
55
+ font-size: 21px;
56
+ }
57
+
58
+ /* Supporting marketing content */
59
+ .marketing {
60
+ margin: 40px 0;
61
+ }
62
+ .marketing p + h4 {
63
+ margin-top: 28px;
64
+ }
65
+
66
+ /* Responsive: Portrait tablets and up */
67
+ @media screen and (min-width: 768px) {
68
+ /* Remove the padding we set earlier */
69
+ .header,
70
+ .marketing,
71
+ .footer {
72
+ padding-right: 0;
73
+ padding-left: 0;
74
+ }
75
+ /* Space out the masthead */
76
+ .header {
77
+ margin-bottom: 30px;
78
+ }
79
+ /* Remove the bottom border on the jumbotron for visual effect */
80
+ .jumbotron {
81
+ border-bottom: 0;
82
+ }
83
+ }
84
+
85
+ #selector {
86
+ width: 600px;
87
+ height: 200px;
88
+ }
app/static/img/setosa.jpg ADDED
app/static/img/versicolor.jpg ADDED
app/static/img/virginica.jpg ADDED
app/templates/index.html ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
+ <meta name="description" content="">
9
+ <meta name="author" content="">
10
+ <link rel="icon" href="../../favicon.ico">
11
+
12
+ <title>VIVADATA |Iris ML</title>
13
+
14
+ <!-- Bootstrap core CSS -->
15
+ <link href="../static/css/bootstrap.min.css" rel="stylesheet">
16
+
17
+ <!-- Custom styles for this template -->
18
+ <link href="../static/css/jumbotron-narrow.css" rel="stylesheet">
19
+
20
+ </head>
21
+
22
+ <body>
23
+
24
+ <div class="container">
25
+ <div class="header clearfix">
26
+ <h3 class="text-muted">VIVADATA - Flask Demo</h3>
27
+ </div>
28
+
29
+ <div class="jumbotron">
30
+ <h1>Predicting Iris 🏡️🌺🌸</h1>
31
+ <p class="lead">Put your iris characteristics to predict its type!</p>
32
+ <!-- <p><a class="btn btn-lg btn-success" href="home" role="button">Get started</a></p> -->
33
+ </div>
34
+ <form action="/predict/" method="post">
35
+ <div class="form-group row">
36
+ <label for="inputSepalLength" class="col-sm-3 col-form-label">Sepal Length</label>
37
+ <div class="col-sm-8">
38
+ <input step="0.01" type="number" class="form-control" id="inputSepalLength" name="inputSepalLength" placeholder="Sepal Length (cm)">
39
+ </div>
40
+ </div>
41
+ <div class="form-group row">
42
+ <label for="inputSepalWidth" class="col-sm-3 col-form-label">Sepal Width</label>
43
+ <div class="col-sm-8">
44
+ <input step="0.01" type="number" class="form-control" id="inputSepalWidth" name="inputSepalWidth" placeholder="Sepal Width (cm)">
45
+ </div>
46
+ </div>
47
+ <div class="form-group row">
48
+ <label for="inputPetalLength" class="col-sm-3 col-form-label">Petal Length</label>
49
+ <div class="col-sm-8">
50
+ <input step="0.01" type="number" class="form-control" id="inputPetalLength" name="inputPetalLength" placeholder="Petal Length (cm)">
51
+ </div>
52
+ </div>
53
+ <div class="form-group row">
54
+ <label for="inputPetalWidth" class="col-sm-3 col-form-label">Petal Width</label>
55
+ <div class="col-sm-8">
56
+ <input step="0.01" type="number" class="form-control" id="inputPetalWidth" name="inputPetalWidth" placeholder="Petal Width (cm)">
57
+ </div>
58
+ </div>
59
+
60
+ <div class="form-group row">
61
+ <div class="col-sm-5">
62
+ <button type="submit" class="btn btn-primary">Predict</button>
63
+ </div>
64
+ </div>
65
+ </form>
66
+
67
+ <footer class="footer">
68
+ <p>&copy; Vivadata 2019</p>
69
+ </footer>
70
+
71
+ </div> <!-- /container -->
72
+ </body>
73
+ </html>
app/templates/index_exemple.html ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <!-- The above 3 meta tags "must" come first in the dead; any other head content must come "after" these tags -->
8
+ <meta name="description" content="">
9
+ <meta name="author" content="">
10
+ <link rel="icon" href="../../favicon.ico">
11
+
12
+ <title>VIVADATA | Profile</title>
13
+
14
+ <!-- Boostrap core CSS -->
15
+ <link href="../static/css/bootstrap.min.css" rel="stylesheet">
16
+
17
+ <!-- Custom styles for this template -->
18
+ <link href="../static/css/jumbotron-narrow.css" rel="stylesheet">
19
+
20
+ </head>
21
+
22
+ <body>
23
+
24
+ <div class="container">
25
+ <div class="header clearfix">
26
+ <h3 class="text-muted">VIVADATA - Flask Demo</h3>
27
+ </div>
28
+
29
+ <div class="jumbotron">
30
+ <h1>Hello {{mon_nom}} πŸ‘‹πŸ™‹πŸ•Ί</h1>
31
+ <p class="lead">This is your custom page</p>
32
+ <!-- <p>>a class="btn btn-lg btn-success" href="home" role="button" >Get started</a></p> -->
33
+ </div>
34
+
35
+ <footer class="footer">
36
+ <p>&copy; Vivadata 2023</p>
37
+ </footer>
38
+
39
+ </div> <!-- /container -->
40
+ </body>
41
+ </html>
app/templates/prediction.html ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
+ <meta name="description" content="">
9
+ <meta name="author" content="">
10
+ <link rel="icon" href="../../favicon.ico">
11
+
12
+ <title>VIVADATA | {{iris_type}}</title>
13
+
14
+ <!-- Bootstrap core CSS -->
15
+ <link href="../static/css/bootstrap.min.css" rel="stylesheet">
16
+
17
+ <!-- Custom styles for this template -->
18
+ <link href="../static/css/jumbotron-narrow.css" rel="stylesheet">
19
+
20
+ </head>
21
+
22
+ <body>
23
+
24
+ <div class="container">
25
+ <div class="header clearfix">
26
+ <h3 class="text-muted">VIVADATA - Flask Demo</h3>
27
+ </div>
28
+
29
+ <div class="jumbotron">
30
+ <h1>🏡️🌺🌸 It's a {{iris_type|title}} 🏡️🌺🌸</h1>
31
+ </div>
32
+ <div class="text-center">
33
+ <img src="../static/img/{{iris_type}}.jpg" class="rounded" alt="setosa" width=300>
34
+ </div>
35
+
36
+ <br>
37
+ <div class="text-center">
38
+ <a href="/" class="btn btn-primary">Back</a>
39
+ </div>
40
+
41
+ <br>
42
+ <footer class="footer">
43
+ <p>&copy; Vivadata 2019</p>
44
+ </footer>
45
+
46
+ </div> <!-- /container -->
47
+ </body>
48
+ </html>