Anthony-Ml commited on
Commit
f597e95
1 Parent(s): 1c07639

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -32
app.py CHANGED
@@ -1,10 +1,8 @@
1
  import gradio as gr
2
- import shap
3
  from fastai.vision.all import *
4
  from efficientnet_pytorch import EfficientNet
5
 
6
 
7
-
8
  title = "COVID_19 Infection Detectation App!"
9
  head = (
10
  "<div>"
@@ -24,36 +22,6 @@ examples = [
24
  ['covid/covid_1031.png']
25
  ]
26
 
27
- # Load the SHAP explainer for your model
28
- explainer = shap.Explainer(model, data=None)
29
-
30
- # Define a function to compute Shapley values for an image
31
- def compute_shapley(image):
32
- # Preprocess the input image (e.g., resize, normalize) to match the model's input requirements
33
- # You should replace this with your specific preprocessing code
34
- image = preprocess_image(image)
35
-
36
- # Compute Shapley values for the input image
37
- shap_values = explainer(image)
38
-
39
- # Convert the Shapley values to a format that can be displayed (e.g., a heatmap)
40
- shap_values_image = shap.image_plot(shap_values[0], image)
41
-
42
- return shap_values_image
43
-
44
- # Define the Gradio interface
45
- image_input = gr.inputs.Image(shape=(224, 224)) # Adjust the shape as needed
46
- shapley_output = gr.outputs.Image()
47
-
48
- def interpreter_func(input_text):
49
- if input_text == "Compute Shapley":
50
- return compute_shapley(image_input)
51
- else:
52
- return None
53
-
54
- interpreter_input = gr.inputs.Textbox(default="Type 'Compute Shapley' and click the button")
55
- interpreter_button = "Generate Shapley"
56
-
57
  #learn = load_learner('model/predictcovidfastaifinal18102023.pkl')
58
  learn = load_learner('model/final_20102023_eb7_model.pkl')
59
 
 
1
  import gradio as gr
 
2
  from fastai.vision.all import *
3
  from efficientnet_pytorch import EfficientNet
4
 
5
 
 
6
  title = "COVID_19 Infection Detectation App!"
7
  head = (
8
  "<div>"
 
22
  ['covid/covid_1031.png']
23
  ]
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  #learn = load_learner('model/predictcovidfastaifinal18102023.pkl')
26
  learn = load_learner('model/final_20102023_eb7_model.pkl')
27