dhhd255 commited on
Commit
dfc5d10
·
1 Parent(s): 00e699b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -23,8 +23,8 @@ with fs.open(custom_model_path, 'rb') as f:
23
  custom_model_file = io.BytesIO(custom_model_content)
24
  custom_model_state_dict = torch.load(custom_model_file, map_location=torch.device('cpu'))
25
 
26
- # Create a new instance of your model
27
- model = MyModel()
28
 
29
  # Load your custom model into the new instance
30
  model.load_state_dict(custom_model_state_dict)
@@ -41,18 +41,6 @@ def image_classifier(image):
41
  image = Image.fromarray(image)
42
  image = data_transform(image)
43
  image = image.unsqueeze(0)
44
-
45
- # Use your custom model for inference
46
- with torch.no_grad():
47
- outputs = model(image)
48
- _, predicted = torch.max(outputs.data, 1)
49
-
50
- # Map the index to a class label
51
- labels = ['Healthy', 'Parkinson']
52
- predicted_label = labels[predicted.item()]
53
-
54
- # Return the result
55
- return outputs[0].numpy(), predicted_label
56
 
57
  # Load and preprocess the image
58
  img_path = '/content/test_image_healthy.png'
 
23
  custom_model_file = io.BytesIO(custom_model_content)
24
  custom_model_state_dict = torch.load(custom_model_file, map_location=torch.device('cpu'))
25
 
26
+ # Create a new instance of your custom model
27
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='/content/efficientnet_b3.pt')
28
 
29
  # Load your custom model into the new instance
30
  model.load_state_dict(custom_model_state_dict)
 
41
  image = Image.fromarray(image)
42
  image = data_transform(image)
43
  image = image.unsqueeze(0)
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  # Load and preprocess the image
46
  img_path = '/content/test_image_healthy.png'