dhhd255 commited on
Commit
4adfae5
1 Parent(s): d2d09f1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -0
README.md CHANGED
@@ -1,3 +1,70 @@
1
  ---
2
  license: mit
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ inference: false
4
+ tags:
5
+ - medical
6
+ - code
7
  ---
8
+ # EfficientNet Parkinson's Prediction Model 🤗
9
+
10
+ This repository contains the Hugging Face EfficientNet model for predicting Parkinson's disease using patient drawings with an accuracy of around 65%.
11
+ Made w/ EfficientNet and Torch.
12
+
13
+ ## Overview
14
+
15
+ Parkinson's disease is a progressive nervous system disorder that affects movement. Symptoms start gradually, sometimes starting with a barely noticeable tremor in just one hand. Tremors are common, but the disorder also commonly causes stiffness or slowing of movement.
16
+
17
+ My model uses the EfficientNet architecture to predict the likelihood of Parkinson's disease in patients by analysing their drawings.
18
+ Feel free to open a pull request and contribute if you want to.
19
+
20
+ ## Dataset
21
+
22
+ The dataset used to train this model was provided by [Kaggle](https://www.kaggle.com/datasets/kmader/parkinsons-drawings).
23
+
24
+ ## Usage
25
+
26
+ ```python
27
+ import torch
28
+ from transformers import AutoModel
29
+ from torch import nn
30
+ from PIL import Image
31
+ import numpy as np
32
+
33
+ # Set the device
34
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
35
+
36
+ # Load the trained model
37
+ model = AutoModel.from_pretrained('/content/final')
38
+
39
+ # Move the model to the device
40
+ model = model.to(device)
41
+
42
+ # Load and resize new image(s)
43
+ image_size = (224, 224)
44
+ new_image = Image.open('/content/health.png').convert('RGB').resize(image_size)
45
+ new_image = np.array(new_image)
46
+ new_image = torch.from_numpy(new_image).transpose(0, 2).float().unsqueeze(0)
47
+
48
+ # Move the data to the device
49
+ new_image = new_image.to(device)
50
+
51
+ # Make predictions using the trained model
52
+ with torch.no_grad():
53
+ predictions = model(new_image)
54
+ logits = predictions.last_hidden_state
55
+ logits = logits.view(logits.shape[0], -1)
56
+ num_classes=2
57
+ feature_reducer = nn.Linear(logits.shape[1], num_classes)
58
+
59
+ logits = logits.to(device)
60
+ feature_reducer = feature_reducer.to(device)
61
+
62
+ logits = feature_reducer(logits)
63
+ predicted_class = torch.argmax(logits, dim=1).item()
64
+ confidence = torch.softmax(logits, dim=1)[0][predicted_class].item()
65
+ if(predicted_class == 0):
66
+ print(f'Predicted class: Parkinson\'s with confidence {confidence:.2f}')
67
+ else:
68
+ print(f'Predicted class: Healthy with confidence {confidence:.2f}')
69
+
70
+