andromeda01111 commited on
Commit
fe2a725
·
verified ·
1 Parent(s): 7716db7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import torch
2
  import torchvision.transforms as transforms
3
- import torchvision.models as models
4
  import gradio as gr
5
  import numpy as np
6
  import tensorflow as tf
@@ -12,17 +11,17 @@ from transformers import ViTForImageClassification, ViTImageProcessor
12
  # Set device
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
 
15
- # Load ViT model from Hugging Face
16
- model_path = "andromeda01111/ViT_BCC" # Ensure this file is uploaded to the Space
17
- state_dict = torch.load(model_path, map_location=device)
18
- vit_model.load_state_dict(state_dict)
19
- vit_model.to(device)
20
  vit_model.eval()
 
21
 
22
- # Load Neural Network model from Hugging Face
23
  nn_model = tf.keras.models.load_model("andromeda01111/NN_BC")
24
 
25
- # Load scaler (ensure it's uploaded in the Hugging Face repo)
26
  scaler = joblib.load("scaler.pkl")
27
 
28
  # Class labels
 
1
  import torch
2
  import torchvision.transforms as transforms
 
3
  import gradio as gr
4
  import numpy as np
5
  import tensorflow as tf
 
11
  # Set device
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
 
14
+ # Load ViT model and processor from Hugging Face
15
+ model_path = "andromeda01111/ViT_BCC"
16
+
17
+ vit_model = ViTForImageClassification.from_pretrained(model_path).to(device)
 
18
  vit_model.eval()
19
+ vit_processor = ViTImageProcessor.from_pretrained(model_path)
20
 
21
+ # Load Neural Network model
22
  nn_model = tf.keras.models.load_model("andromeda01111/NN_BC")
23
 
24
+ # Load scaler
25
  scaler = joblib.load("scaler.pkl")
26
 
27
  # Class labels