nazlicanto commited on
Commit
09d042e
1 Parent(s): 6e3cb6a

Update app06.py

Browse files
Files changed (1) hide show
  1. app06.py +6 -8
app06.py CHANGED
@@ -1,17 +1,15 @@
1
  import streamlit as st
2
- from transformers import SegformerForSemanticSegmentation, SegformerImageProcessor, SegformerConfig
3
  from PIL import Image
4
  import numpy as np
5
  import torch
6
- import os
7
 
8
- model_path = "/home/user/app/defectdetection/model"
9
- config = SegformerConfig.from_json_file(os.path.join(model_path, "config.json"))
10
 
11
- model = SegformerForSemanticSegmentation(config=config)
12
- model.load_state_dict(torch.load(os.path.join(model_path, "pytorch_model.bin")))
13
-
14
- preprocessor = SegformerImageProcessor.from_pretrained(model_path, local_files_only=True)
15
 
16
  st.title("PCB Defect Detection")
17
 
 
1
  import streamlit as st
2
+ from transformers import SegformerForSemanticSegmentation, SegformerImageProcessor
3
  from PIL import Image
4
  import numpy as np
5
  import torch
 
6
 
7
+ # Define the model path
8
+ model_hub_path = "nazlicanto/model_defectdetection"
9
 
10
+ # Load the model and preprocessor
11
+ model = SegformerForSemanticSegmentation.from_pretrained(model_hub_path)
12
+ preprocessor = SegformerImageProcessor.from_pretrained(model_hub_path)
 
13
 
14
  st.title("PCB Defect Detection")
15