SamT6 commited on
Commit
3e2d424
1 Parent(s): a9c5b4f

model from aws

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -5,10 +5,15 @@ import tensorflow as tf
5
  import random
6
  from tensorflow import keras
7
 
 
8
 
9
- damage_types = np.array(sorted(['yes', 'no']))
 
 
 
 
10
  disaster_types = np.array(sorted(['volcano', 'flooding', 'earthquake', 'fire', 'wind', 'tsunami']))
11
- # model = keras.models.load_model('Disaster-Classification')
12
 
13
  def damage_classification(img):
14
  prediction = np.random.rand(1, 2)[0]
@@ -17,8 +22,8 @@ def damage_classification(img):
17
  def disaster_classification(img):
18
  image = np.zeros((1, 1024, 1024, 3), dtype=np.uint8)
19
  image[0] = img
20
- # prediction = model.predict(image).tolist()[0]
21
- prediction = np.random.rand(1, 6)[0]
22
  return {disaster_types[i]: prediction[i] for i in range(len(disaster_types))}
23
 
24
  iface = gr.Interface(
 
5
  import random
6
  from tensorflow import keras
7
 
8
+ from cloudpathlib import CloudPath
9
 
10
+ cp = CloudPath("s3://soteria-ml-models/")
11
+ cp.download_to("./models")
12
+
13
+
14
+ damage_types = np.array(sorted(['disaster happened', 'no disaster happened']))
15
  disaster_types = np.array(sorted(['volcano', 'flooding', 'earthquake', 'fire', 'wind', 'tsunami']))
16
+ model = keras.models.load_model('./models/disaster-classification')
17
 
18
  def damage_classification(img):
19
  prediction = np.random.rand(1, 2)[0]
 
22
  def disaster_classification(img):
23
  image = np.zeros((1, 1024, 1024, 3), dtype=np.uint8)
24
  image[0] = img
25
+ prediction = model.predict(image).tolist()[0]
26
+ # prediction = np.random.rand(1, 6)[0]
27
  return {disaster_types[i]: prediction[i] for i in range(len(disaster_types))}
28
 
29
  iface = gr.Interface(