aje6 commited on
Commit
bc0ea23
·
verified ·
1 Parent(s): 743f363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -210,7 +210,7 @@ from ultralytics import YOLO
210
  model = YOLO("Model_IV.pt")
211
  # model = torch.load("Model_IV.pt")
212
  # model.eval()
213
- # checkpoint = torch.load("Model_IV.pt")
214
  # model.load_state_dict(checkpoint) # Load the saved weights
215
  # model.eval() # Set the model to evaluation mode
216
 
@@ -238,18 +238,18 @@ model = YOLO("Model_IV.pt")
238
  # print(checkpoint.keys())
239
 
240
  # Define preprocessing
241
- # transform = T.Compose([
242
- # T.Resize((224, 224)), # Adjust to your model's input size
243
- # T.ToTensor(),
244
- # ])
245
 
246
  def predict(image):
247
- # # Preprocess the image
248
- # img_tensor = transform(image).unsqueeze(0) # Add batch dimension
249
 
250
- # # Make prediction
251
- # with torch.no_grad():
252
- # output = model(img_tensor)
253
 
254
  # Process output (adjust based on your model's format)
255
  # return output # or post-process the results as needed
 
210
  model = YOLO("Model_IV.pt")
211
  # model = torch.load("Model_IV.pt")
212
  # model.eval()
213
+ checkpoint = torch.load("Model_IV.pt")
214
  # model.load_state_dict(checkpoint) # Load the saved weights
215
  # model.eval() # Set the model to evaluation mode
216
 
 
238
  # print(checkpoint.keys())
239
 
240
  # Define preprocessing
241
+ transform = T.Compose([
242
+ T.Resize((224, 224)), # Adjust to your model's input size
243
+ T.ToTensor(),
244
+ ])
245
 
246
  def predict(image):
247
+ # Preprocess the image
248
+ img_tensor = transform(image).unsqueeze(0) # Add batch dimension
249
 
250
+ # Make prediction
251
+ with torch.no_grad():
252
+ output = model(img_tensor)
253
 
254
  # Process output (adjust based on your model's format)
255
  # return output # or post-process the results as needed