sowbaranika13 commited on
Commit
505fe8d
·
verified ·
1 Parent(s): ce7f3ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -16,6 +16,18 @@ labels = {
16
  'amphibia': ['American Bullfrog', 'American Toad', 'Green Frog', 'Northern Leopard Frog']
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # Preprocess the image
20
  def preprocess_image(image):
21
  img = image.resize((224, 224)) # MobileNet requires 224x224 input size
@@ -27,7 +39,7 @@ def preprocess_image(image):
27
  # Function to perform inference
28
  def predict(img):
29
  img_array, resized_img = preprocess_image(img)
30
- model = load_model(r"inceptionv3_classs.h5")
31
  preds = model.predict(img_array) # Get the model predictions
32
  decoded_preds = np.argmax(preds)
33
 
 
16
  'amphibia': ['American Bullfrog', 'American Toad', 'Green Frog', 'Northern Leopard Frog']
17
  }
18
 
19
+ model_url = "https://github.com/sowbaranika1302/ohio_classifier/raw/main/Models/inceptionv3_best_withoutblanks.h5"
20
+ model_path = "inceptionv3_best_withoutblanks.h5"
21
+
22
+ # Download the model if it doesn't exist locally
23
+ if not os.path.exists(model_path):
24
+ response = requests.get(model_url)
25
+ with open(model_path, 'wb') as f:
26
+ f.write(response.content)
27
+
28
+ # Load the model
29
+ model = load_model(model_path)
30
+
31
  # Preprocess the image
32
  def preprocess_image(image):
33
  img = image.resize((224, 224)) # MobileNet requires 224x224 input size
 
39
  # Function to perform inference
40
  def predict(img):
41
  img_array, resized_img = preprocess_image(img)
42
+ #model = load_model(r"inceptionv3_classs.h5")
43
  preds = model.predict(img_array) # Get the model predictions
44
  decoded_preds = np.argmax(preds)
45