Rathapoom commited on
Commit
a30e579
1 Parent(s): 6fac368

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -1,30 +1,30 @@
1
  import numpy as np
2
  import gradio as gr
 
3
 
 
4
  def ovarian(Shadow, Solid, Menopause, CA125):
5
-
6
  if Shadow == "Yes":
7
- Shadow = 1
8
  else:
9
- Shadow = 0
10
  if Solid == "Yes":
11
- Solid = 1
12
  else:
13
- Solid = 0
14
  if Menopause == "Yes":
15
- Menopause = 1
16
  else:
17
- Menopause = 0
18
  if CA125 == "Yes":
19
- CA125 = 1
20
  else:
21
- CA125 = 0
22
 
23
- #print(Shadow, Solid, Menopause, CA125)
24
- logit_P = -3.771109 - 2.293585*Shadow + 3.877268*Solid + 1.76309*Menopause + 1.320551*CA125
25
- e_logit_P = 2.71828182846 ** logit_P
26
- prob = e_logit_P/(1+e_logit_P) * 100
27
- return "Risk of Ovarian cancer in this patient : \n" + str('%.3f' %(prob)) + " %" + "\n[Following up on the Predictive Model for Ovarian Cancer.]"
28
 
29
  demo = gr.Interface(
30
  ovarian,
@@ -42,4 +42,4 @@ demo = gr.Interface(
42
  description="Here is a predictive model for ovarian cancer. Choose any four of the risk factors listed below for your patient. This model allows you to calculate the risk of ovarian cancer based on these selected factors.",
43
  )
44
 
45
- demo.launch()
 
1
  import numpy as np
2
  import gradio as gr
3
+ import spaces
4
 
5
+ @spaces.GPU # Decorate the function to utilize GPU
6
  def ovarian(Shadow, Solid, Menopause, CA125):
 
7
  if Shadow == "Yes":
8
+ Shadow = 1
9
  else:
10
+ Shadow = 0
11
  if Solid == "Yes":
12
+ Solid = 1
13
  else:
14
+ Solid = 0
15
  if Menopause == "Yes":
16
+ Menopause = 1
17
  else:
18
+ Menopause = 0
19
  if CA125 == "Yes":
20
+ CA125 = 1
21
  else:
22
+ CA125 = 0
23
 
24
+ logit_P = -3.771109 - 2.293585 * Shadow + 3.877268 * Solid + 1.76309 * Menopause + 1.320551 * CA125
25
+ e_logit_P = np.exp(logit_P)
26
+ prob = e_logit_P / (1 + e_logit_P) * 100
27
+ return "Risk of Ovarian cancer in this patient : \n" + str('%.3f' % (prob)) + " %" + "\n[Following up on the Predictive Model for Ovarian Cancer.]"
 
28
 
29
  demo = gr.Interface(
30
  ovarian,
 
42
  description="Here is a predictive model for ovarian cancer. Choose any four of the risk factors listed below for your patient. This model allows you to calculate the risk of ovarian cancer based on these selected factors.",
43
  )
44
 
45
+ demo.launch()