Nathanotal commited on
Commit
9154a27
·
1 Parent(s): 47157c3
Files changed (4) hide show
  1. .hw_api_key +1 -0
  2. README.md +5 -5
  3. app.py +50 -0
  4. requirements.txt +4 -0
.hw_api_key ADDED
@@ -0,0 +1 @@
 
 
1
+ gJHnXNU7BFSJKue3.9GJb8V4qJRXE7Vn25uM6mDb39eOZIstYWJZ8XbgU7Fo6rlCZlzE3JNkcwDAYaAUJ
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Titanic
3
- emoji: 🐠
4
- colorFrom: pink
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 3.9.1
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
1
  ---
2
+ title: Iris
3
+ emoji: 🐢
4
+ colorFrom: purple
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.5
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+ import requests
5
+ import pandas as pd
6
+
7
+ import hopsworks
8
+ import joblib
9
+
10
+ project = hopsworks.login()
11
+ fs = project.get_feature_store()
12
+
13
+
14
+ mr = project.get_model_registry()
15
+ model = mr.get_model("titanic_modal", version=1)
16
+ model_dir = model.download()
17
+ model = joblib.load(model_dir + "/titanic_model.pkl")
18
+
19
+ df = pd
20
+ features = pd.read_csv(
21
+ "https://raw.githubusercontent.com/Nathanotal/remoteFiles/main/titanicCleaned.csv")
22
+ features = features.drop(columns=["survived"])
23
+ featureLabels = features.columns
24
+
25
+
26
+ def titanic(input_list):
27
+ # 'res' is a list of predictions returned as the label.
28
+ res = model.predict(np.asarray(input_list).reshape(1, -1))
29
+
30
+ # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
31
+ # the first element.
32
+ # Todo: survivor, "https://fakeface.rest/face/json?maximum_age=50&gender=female&minimum_age=49"
33
+ survivor_url = 'https://picsum.photos/200/300'
34
+ img = Image.open(requests.get(survivor_url, stream=True).raw)
35
+ return img
36
+
37
+
38
+ inputs = []
39
+ for feature in featureLabels:
40
+ inputs.append(gr.inputs.Number(minimum=0, default=1.0, label=feature))
41
+
42
+ demo = gr.Interface(
43
+ fn=titanic,
44
+ title="Titanic Survivor Predictive Analytics",
45
+ description="Experiment with person features to predict which survivor it is.",
46
+ allow_flagging="never",
47
+ inputs=inputs,
48
+ outputs=gr.Image(type="pil"))
49
+
50
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ hopsworks
2
+ joblib
3
+ scikit-learn
4
+ gradio