gmustafa413 commited on
Commit
5b882c7
·
verified ·
1 Parent(s): b9b7ef6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -68,7 +68,7 @@ class resnet_feature_extractor(torch.nn.Module):
68
 
69
  return patch
70
 
71
- image = Image.open(r'/content/transistor/test/good/000.png')
72
  image = transform(image).unsqueeze(0)
73
 
74
  backbone = resnet_feature_extractor()
@@ -83,7 +83,7 @@ print(feature.shape)
83
 
84
  memory_bank =[]
85
 
86
- folder_path = Path(r'/content/transistor/train/good')
87
 
88
  for pth in tqdm(folder_path.iterdir(),leave=False):
89
  with torch.no_grad():
@@ -95,7 +95,7 @@ memory_bank = torch.cat(memory_bank,dim=0)
95
 
96
  y_score=[]
97
 
98
- folder_path = Path(r'/content/transistor/train/good')
99
 
100
  for pth in tqdm(folder_path.iterdir(),leave=False):
101
  data = transform(Image.open(pth)).unsqueeze(0)
@@ -121,7 +121,7 @@ y_score = []
121
  y_true=[]
122
 
123
  for classes in ['bent_lead','good','cut_lead','damaged_case','misplaced']:
124
- folder_path = Path(r'/content/transistor/test/{}'.format(classes))
125
 
126
  for pth in tqdm(folder_path.iterdir(),leave=False):
127
 
@@ -146,7 +146,7 @@ plt.vlines(x=best_threshold,ymin=0,ymax=30,color='r')
146
  plt.show()
147
 
148
 
149
- test_image = transform(Image.open(r'/content/transistor/test/good/000.png')).unsqueeze(0)
150
  features = backbone(test_image)
151
 
152
  distances = torch.cdist(features, memory_bank, p=2.0)
 
68
 
69
  return patch
70
 
71
+ image = Image.open(r'transistor/test/good/000.png')
72
  image = transform(image).unsqueeze(0)
73
 
74
  backbone = resnet_feature_extractor()
 
83
 
84
  memory_bank =[]
85
 
86
+ folder_path = Path(r'transistor/train/good')
87
 
88
  for pth in tqdm(folder_path.iterdir(),leave=False):
89
  with torch.no_grad():
 
95
 
96
  y_score=[]
97
 
98
+ folder_path = Path(r'transistor/train/good')
99
 
100
  for pth in tqdm(folder_path.iterdir(),leave=False):
101
  data = transform(Image.open(pth)).unsqueeze(0)
 
121
  y_true=[]
122
 
123
  for classes in ['bent_lead','good','cut_lead','damaged_case','misplaced']:
124
+ folder_path = Path(r'transistor/test/{}'.format(classes))
125
 
126
  for pth in tqdm(folder_path.iterdir(),leave=False):
127
 
 
146
  plt.show()
147
 
148
 
149
+ test_image = transform(Image.open(r'transistor/test/good/000.png')).unsqueeze(0)
150
  features = backbone(test_image)
151
 
152
  distances = torch.cdist(features, memory_bank, p=2.0)