brightlembo commited on
Commit
09d9434
·
verified ·
1 Parent(s): ea34ce2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import torch
3
- from torchvision import transforms
4
  from PIL import Image
5
  import requests
6
  import json
@@ -31,8 +31,11 @@ with open(CLASS_NAMES_PATH, "r") as f:
31
  # Charger le modèle
32
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
33
  try:
34
- model = torch.load(MODEL_PATH, map_location=device,weights_only=True)
35
- model.eval()
 
 
 
36
  except Exception as e:
37
  st.error(f"Erreur lors du chargement du modèle : {e}")
38
  st.stop()
 
1
  import streamlit as st
2
  import torch
3
+ from torchvision import transforms, models
4
  from PIL import Image
5
  import requests
6
  import json
 
31
  # Charger le modèle
32
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
33
  try:
34
+ # Créer le modèle EfficientNet
35
+ model = models.efficientnet_b7(pretrained=False) # Initialisation du modèle sans poids pré-entrainés
36
+ # Charger les poids du modèle
37
+ model.load_state_dict(torch.load(MODEL_PATH, map_location=device))
38
+ model.eval() # Passer en mode évaluation
39
  except Exception as e:
40
  st.error(f"Erreur lors du chargement du modèle : {e}")
41
  st.stop()