Jose M Delgado commited on
Commit
e2f6cfc
1 Parent(s): 375c0e8

test images, metadata

Browse files
Files changed (5) hide show
  1. app.py +20 -4
  2. test/mild.png +3 -0
  3. test/moderate.png +3 -0
  4. test/no_retinopathy.png +3 -0
  5. test/severe.png +3 -0
app.py CHANGED
@@ -2,17 +2,27 @@ import gradio as gr
2
  from fastai.vision.all import *
3
  import skimage
4
 
5
- def get_x(r): return "/kaggle/input/aptos2019/train_images/train_images/1ae8c165fd53.png"
6
 
7
  def get_y(r): return r['diagnosis']
8
 
9
  learn = load_learner('model.pkl')
10
  labels = learn.dls.vocab
11
 
 
 
 
 
 
 
 
 
 
12
  def predict(img):
13
  img = PILImage.create(img)
14
  pred,pred_idx,probs = learn.predict(img)
15
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
16
 
17
  title = "Proliferative Retinopathy Detection"
18
  description = """Detects severity of diabetic retinopathy -
@@ -28,11 +38,17 @@ description = """Detects severity of diabetic retinopathy -
28
  4 - Proliferative DR
29
  """
30
  article="<p style='text-align: center'><a href='https://www.kaggle.com/code/josemauriciodelgado/proliferative-retinopathy' target='_blank'>Notebook</a></p>"
31
- interpretation='default'
32
- enable_queue=True
 
 
33
 
34
  gr.Interface(
35
  fn=predict,
36
  inputs=gr.Image(),
37
  outputs=gr.Label(num_top_classes=5),
 
 
 
 
38
  ).launch()
 
2
  from fastai.vision.all import *
3
  import skimage
4
 
5
+ def get_x(r): return ""
6
 
7
  def get_y(r): return r['diagnosis']
8
 
9
  learn = load_learner('model.pkl')
10
  labels = learn.dls.vocab
11
 
12
+ # Define the mapping from label numbers to descriptions
13
+ label_descriptions = {
14
+ 0: "No DR",
15
+ 1: "Mild",
16
+ 2: "Moderate",
17
+ 3: "Severe",
18
+ 4: "Proliferative DR"
19
+ }
20
+
21
  def predict(img):
22
  img = PILImage.create(img)
23
  pred,pred_idx,probs = learn.predict(img)
24
+ # Use the label_descriptions dictionary to return descriptions instead of numbers
25
+ return {label_descriptions[labels[i]]: float(probs[i]) for i in range(len(labels))}
26
 
27
  title = "Proliferative Retinopathy Detection"
28
  description = """Detects severity of diabetic retinopathy -
 
38
  4 - Proliferative DR
39
  """
40
  article="<p style='text-align: center'><a href='https://www.kaggle.com/code/josemauriciodelgado/proliferative-retinopathy' target='_blank'>Notebook</a></p>"
41
+
42
+ # Get a list of all image paths in the test folder
43
+ test_folder = "test" # replace with the actual path to your test folder
44
+ image_paths = [os.path.join(test_folder, img) for img in os.listdir(test_folder) if img.endswith(('.png', '.jpg', '.jpeg'))]
45
 
46
  gr.Interface(
47
  fn=predict,
48
  inputs=gr.Image(),
49
  outputs=gr.Label(num_top_classes=5),
50
+ examples=image_paths, # set the examples parameter to the list of image paths
51
+ article=article,
52
+ title=title,
53
+ description=description,
54
  ).launch()
test/mild.png ADDED

Git LFS Details

  • SHA256: ef0bda2c21f3dbe839b4e5168fa7e52afe61e6923a56fd625bba0ddc1665d1d8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
test/moderate.png ADDED

Git LFS Details

  • SHA256: 3f34b577a7102dddea20d2aaed76028bcf724ddb82e923b5699474d3272510f9
  • Pointer size: 132 Bytes
  • Size of remote file: 3.22 MB
test/no_retinopathy.png ADDED

Git LFS Details

  • SHA256: c18a236541ae3d3ddbf8cf3eae991b4ff28446c5313b3dc2afa2506fa4cb60c1
  • Pointer size: 131 Bytes
  • Size of remote file: 975 kB
test/severe.png ADDED

Git LFS Details

  • SHA256: 6caef7f25e09486785215d517a03d610048d026b6dc7ea26b7d9eee7f6e1e27f
  • Pointer size: 132 Bytes
  • Size of remote file: 2.44 MB