yolac commited on
Commit
ca8dd76
·
verified ·
1 Parent(s): b1cfa7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -51,11 +51,11 @@ try:
51
  except Exception as e:
52
  print(f"Error loading the model: {e}")
53
 
54
- # Define image preprocessing
55
  transform = transforms.Compose([
56
- transforms.Resize((224, 224)),
57
- transforms.ToTensor(),
58
- transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
59
  ])
60
 
61
  # Prediction function
@@ -98,3 +98,4 @@ interface = gr.Interface(
98
  # Launch the app
99
  if __name__ == "__main__":
100
  interface.launch()
 
 
51
  except Exception as e:
52
  print(f"Error loading the model: {e}")
53
 
54
+ # Define image preprocessing to match training preprocessing
55
  transform = transforms.Compose([
56
+ transforms.Resize((224, 224)), # Resize to match model input size
57
+ transforms.ToTensor(), # Convert to a tensor
58
+ transforms.Normalize(mean=[0, 0, 0], std=[1/255, 1/255, 1/255]), # Scale pixel values to [0, 1]
59
  ])
60
 
61
  # Prediction function
 
98
  # Launch the app
99
  if __name__ == "__main__":
100
  interface.launch()
101
+