test
Browse files
app.py
CHANGED
@@ -47,13 +47,21 @@ topt = A.Compose([
|
|
47 |
labels = ['good', 'ill']
|
48 |
|
49 |
def predict(inp):
|
|
|
|
|
|
|
50 |
img = ho_trans_center(image = inp)['image']
|
51 |
img = topt(image = img)['image']
|
52 |
img = img.unsqueeze(0)
|
53 |
with torch.no_grad():
|
54 |
prediction = model(img).softmax(1).numpy()
|
55 |
confidences = {labels[i]: float(prediction[0][i]) for i in range(2)}
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
import gradio as gr
|
59 |
|
|
|
47 |
labels = ['good', 'ill']
|
48 |
|
49 |
def predict(inp):
|
50 |
+
target_layers = [model.norm_pre]
|
51 |
+
cam = GradCAM(model=model,
|
52 |
+
target_layers=target_layers)
|
53 |
img = ho_trans_center(image = inp)['image']
|
54 |
img = topt(image = img)['image']
|
55 |
img = img.unsqueeze(0)
|
56 |
with torch.no_grad():
|
57 |
prediction = model(img).softmax(1).numpy()
|
58 |
confidences = {labels[i]: float(prediction[0][i]) for i in range(2)}
|
59 |
+
grad = cam(input_tensor=img,
|
60 |
+
targets=None,
|
61 |
+
# eigen_smooth=args.eigen_smooth,
|
62 |
+
# aug_smooth=args.aug_smooth
|
63 |
+
)
|
64 |
+
return confidences, grad[0, :]
|
65 |
|
66 |
import gradio as gr
|
67 |
|