Zeeshan01 commited on
Commit
f082e58
·
1 Parent(s): 73c101f

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. O1.jpg +0 -0
  2. O2.jpg +0 -0
  3. O3.jpg +0 -0
  4. __pycache__/app.cpython-310.pyc +0 -0
  5. app.py +15 -31
O1.jpg CHANGED
O2.jpg CHANGED
O3.jpg CHANGED
__pycache__/app.cpython-310.pyc CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
 
app.py CHANGED
@@ -12,39 +12,23 @@ from PIL import Image
12
  IMG_SIZE = 300
13
 
14
 
15
-
16
- labelInfo = {
17
- 'lower-gi-tract anatomical-landmarks cecum': 0,
18
- 'lower-gi-tract anatomical-landmarks ileum': 1,
19
- 'lower-gi-tract anatomical-landmarks retroflex-rectum': 2,
20
- 'lower-gi-tract pathological-findings hemorrhoids': 3,
21
- 'lower-gi-tract pathological-findings polyps': 4,
22
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-0-1': 5,
23
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-1': 6,
24
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-1-2': 7,
25
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-2': 8,
26
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-2-3': 9,
27
- 'lower-gi-tract pathological-findings ulcerative-colitis-grade-3': 10,
28
- 'lower-gi-tract quality-of-mucosal-views bbps-0-1': 11,
29
- 'lower-gi-tract quality-of-mucosal-views bbps-2-3': 12,
30
- 'lower-gi-tract quality-of-mucosal-views impacted-stool': 13,
31
- 'lower-gi-tract therapeutic-interventions dyed-lifted-polyps': 14,
32
- 'lower-gi-tract therapeutic-interventions dyed-resection-margins': 15,
33
- 'upper-gi-tract anatomical-landmarks pylorus': 16,
34
- 'upper-gi-tract anatomical-landmarks retroflex-stomach': 17,
35
- 'upper-gi-tract anatomical-landmarks z-line': 18,
36
- 'upper-gi-tract pathological-findings barretts': 19,
37
- 'upper-gi-tract pathological-findings barretts-short-segment': 20,
38
- 'upper-gi-tract pathological-findings esophagitis-a': 21,
39
- 'upper-gi-tract pathological-findings esophagitis-b-d': 22
40
  }
41
  # Load the model from the H5 file
42
- model = tf.keras.models.load_model('model/Hyper.h5')
43
 
44
  # Define the prediction function
45
  def predict(img):
46
- img_height = 300
47
- img_width = 300
48
 
49
  # Convert the NumPy array to a PIL Image object
50
  pil_img = Image.fromarray(img)
@@ -61,7 +45,7 @@ def predict(img):
61
 
62
  predi = model.predict(x)
63
  accuracy_of_class = '{:.1f}'.format(predi[0][np.argmax(predi)] * 100) + "%"
64
- classes = list(labelInfo.keys())[np.argmax(predi)]
65
  context = {
66
  'predictedLabel': classes,
67
  # 'y_class': y_class,
@@ -75,7 +59,7 @@ def predict(img):
75
 
76
 
77
 
78
- demo = gr.Interface(fn=predict, inputs="image", outputs="text" , examples=[["O1.jpg"],["O2.jpg"],["O3.jpg"]],)
79
 
80
- demo.launch(server_port=8000)
81
 
 
12
  IMG_SIZE = 300
13
 
14
 
15
+ labelOcular = {
16
+ 'normal': 0,
17
+ 'diabetes': 1,
18
+ 'glaucoma': 2,
19
+ 'cataract': 3,
20
+ 'amd': 4,
21
+ 'hypertension': 5,
22
+ 'myopia': 6,
23
+ 'other': 7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
  # Load the model from the H5 file
26
+ model = tf.keras.models.load_model('model/Ocular.h5')
27
 
28
  # Define the prediction function
29
  def predict(img):
30
+ img_height = 224
31
+ img_width = 224
32
 
33
  # Convert the NumPy array to a PIL Image object
34
  pil_img = Image.fromarray(img)
 
45
 
46
  predi = model.predict(x)
47
  accuracy_of_class = '{:.1f}'.format(predi[0][np.argmax(predi)] * 100) + "%"
48
+ classes = list(labelOcular.keys())[np.argmax(predi)]
49
  context = {
50
  'predictedLabel': classes,
51
  # 'y_class': y_class,
 
59
 
60
 
61
 
62
+ demo = gr.Interface(fn=predict, inputs="image", outputs="text" , examples=[["O1.jpg"],["O2.jpg"],["O2.jpg"]],)
63
 
64
+ demo.launch()
65