ErnestBeckham commited on
Commit
b717a9c
·
verified ·
1 Parent(s): d80c331
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -2,18 +2,34 @@ import streamlit as st
2
  import tensorflow as tf
3
  import cv2
4
  import numpy as np
5
- from huggingface_hub import from_pretrained_keras
6
  from lime import lime_image
7
  from skimage.segmentation import mark_boundaries
8
  import matplotlib.pyplot as plt
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
11
  #model = tf.keras.models.load_model("model/resnet_for_breast_cancer-v1.h5")
12
- model = from_pretrained_keras("ErnestBeckham/BreastResViT-II")
13
  explainer = lime_image.LimeImageExplainer()
14
 
15
- hp = {}
16
- hp['class_names'] = ["breast_benign", "breast_malignant"]
17
 
18
  def main():
19
  st.title("Breast Cancer Classification")
 
2
  import tensorflow as tf
3
  import cv2
4
  import numpy as np
 
5
  from lime import lime_image
6
  from skimage.segmentation import mark_boundaries
7
  import matplotlib.pyplot as plt
8
+ from vit import CNN_ViT
9
 
10
+ hp = {}
11
+ hp['image_size'] = 512
12
+ hp['num_channels'] = 3
13
+ hp['patch_size'] = 64
14
+ hp['num_patches'] = (hp['image_size']**2) // (hp["patch_size"]**2)
15
+ hp["flat_patches_shape"] = (hp["num_patches"], hp['patch_size']*hp['patch_size']*hp["num_channels"])
16
+ hp['batch_size'] = 32
17
+ hp['lr'] = 1e-4
18
+ hp["num_epochs"] = 30
19
+ hp['num_classes'] = 2
20
+ hp["num_layers"] = 12
21
+ hp["hidden_dim"] = 512
22
+ hp["mlp_dim"] = 3072
23
+ hp['num_heads'] = 12
24
+ hp['dropout_rate'] = 0.1
25
+ hp['class_names'] = ["breast_benign", "breast_malignant"]
26
 
27
+ model = CNN_ViT(hp)
28
+ model.load_weights("model/ResViT_for_breast_cancer_classification(1).keras")
29
  #model = tf.keras.models.load_model("model/resnet_for_breast_cancer-v1.h5")
30
+ #model = from_pretrained_keras("ErnestBeckham/BreastResViT-II")
31
  explainer = lime_image.LimeImageExplainer()
32
 
 
 
33
 
34
  def main():
35
  st.title("Breast Cancer Classification")