brightlembo commited on
Commit
3e0991a
·
verified ·
1 Parent(s): 401a016

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -1,21 +1,17 @@
1
  import torch
2
- from torchvision import transforms, models
3
  from PIL import Image
4
- import json
5
  import streamlit as st
 
6
 
7
  # Charger les noms des classes
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)
 
1
  import torch
2
+ from torchvision import transforms
3
  from PIL import Image
 
4
  import streamlit as st
5
+ import json
6
 
7
  # Charger les noms des classes
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 = torch.load("efficientnet_b7_best.pth", map_location=device)
14
+ model.eval() # Mode évaluation
 
 
 
15
 
16
  # Définir la taille de l'image
17
  image_size = (224, 224)