brightlembo commited on
Commit
401a016
·
verified ·
1 Parent(s): 293adc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -8,11 +8,14 @@ import streamlit as st
8
  with open("class_names.json", "r") as f:
9
  class_names = json.load(f)
10
 
 
11
  # Charger le modèle
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
- model = models.efficientnet_b7(pretrained=False)
14
- model = torch.load("efficientnet_b7_best.pth", map_location=device)
15
- model.eval() # Mode évaluation
 
 
16
 
17
  # Définir la taille de l'image
18
  image_size = (224, 224)
 
8
  with open("class_names.json", "r") as f:
9
  class_names = json.load(f)
10
 
11
+
12
  # Charger le modèle
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
+ model = models.efficientnet_b7(pretrained=False) # Initialize the model architecture
15
+ model.load_state_dict(torch.load("efficientnet_b7_best.pth", map_location=device)) # Load the saved weights
16
+ model = model.to(device) # Move model to the appropriate device (GPU/CPU)
17
+ model.eval() # Set the model to evaluation mode
18
+
19
 
20
  # Définir la taille de l'image
21
  image_size = (224, 224)