dhhd255 commited on
Commit
a887793
·
1 Parent(s): e2ad134

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import streamlit as st
2
  import torch
3
  from torchvision import transforms
4
  from efficientnet_pytorch import EfficientNet
@@ -7,17 +6,17 @@ from PIL import Image
7
 
8
  # Authenticate and download the custom model from Hugging Face Spaces
9
  fs = HfFileSystem()
10
- model_path = 'dhhd255/efficient_net_parkinsons/best_model.pth'
11
  with fs.open(model_path, 'rb') as f:
12
  model_content = f.read()
13
 
14
  # Save the model file to disk
15
- with open('best_model.pth', 'wb') as f:
16
  f.write(model_content)
17
 
18
  # Load your custom model onto the CPU
19
  model = EfficientNet.from_pretrained('efficientnet-b3')
20
- model.load_state_dict(torch.load('best_model.pth', map_location=torch.device('cpu')))
21
  model.eval()
22
 
23
  # Define a function that takes an image as input and uses the model for inference
 
 
1
  import torch
2
  from torchvision import transforms
3
  from efficientnet_pytorch import EfficientNet
 
6
 
7
  # Authenticate and download the custom model from Hugging Face Spaces
8
  fs = HfFileSystem()
9
+ model_path = 'dhhd255/efficientnet_b3/efficientnet_b3.pt'
10
  with fs.open(model_path, 'rb') as f:
11
  model_content = f.read()
12
 
13
  # Save the model file to disk
14
+ with open('efficientnet_b3.pt', 'wb') as f:
15
  f.write(model_content)
16
 
17
  # Load your custom model onto the CPU
18
  model = EfficientNet.from_pretrained('efficientnet-b3')
19
+ model.load_state_dict(torch.load('efficientnet_b3.pt', map_location=torch.device('cpu')))
20
  model.eval()
21
 
22
  # Define a function that takes an image as input and uses the model for inference