fmegahed commited on
Commit
d11d507
·
1 Parent(s): 92523f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -13,7 +13,8 @@ import numpy as np
13
  import io
14
  import pickle
15
  import requests
16
- from urllib.request import urlopen
 
17
 
18
  url = 'https://raw.githubusercontent.com/fmegahed/tavr_paper/main/data/example_data2.csv'
19
  download = requests.get(url).content
@@ -34,10 +35,11 @@ def predict(age, female, race, elective, aweekend, zipinc_qrtl, hosp_region, hos
34
  pulmonary_circulation_disorder, smoker, valvular_disease, weight_loss,
35
  endovascular_tavr, transapical_tavr):
36
 
37
- url = 'https://github.com/fmegahed/tavr_paper/blob/main/data/final_model.pkl?raw=true'
38
- raw = urlopen(url)
39
- model = pickle.load(raw)
40
- model = load_model(model)
 
41
 
42
  df = pd.DataFrame.from_dict({
43
  'age': [age], 'female': [female], 'race': [race], 'elective': elective,
 
13
  import io
14
  import pickle
15
  import requests
16
+ import urllib.request
17
+ import shutil
18
 
19
  url = 'https://raw.githubusercontent.com/fmegahed/tavr_paper/main/data/example_data2.csv'
20
  download = requests.get(url).content
 
35
  pulmonary_circulation_disorder, smoker, valvular_disease, weight_loss,
36
  endovascular_tavr, transapical_tavr):
37
 
38
+ with urllib.request.urlopen('https://github.com/fmegahed/tavr_paper/blob/main/data/final_model.pkl?raw=true') as response,
39
+ open('final_model.pkl', 'wb') as out_file:
40
+ shutil.copyfileobj(response, out_file)
41
+
42
+ model = load_model('final_model')
43
 
44
  df = pd.DataFrame.from_dict({
45
  'age': [age], 'female': [female], 'race': [race], 'elective': elective,