Kaushik066 commited on
Commit
3accedb
·
verified ·
1 Parent(s): 66f68c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -165,8 +165,8 @@ prod_ds = dataset_prod_obj.create_dataset(image_paths)
165
  prod_dl = DataLoader(prod_ds, batch_size=BATCH_SIZE)
166
 
167
  # Testing the dataloader
168
- prod_inputs = next(iter(prod_dl))
169
- st.write(prod_inputs['pixel_values'].shape)
170
 
171
  # Read image from Camera
172
  enable = st.checkbox("Enable camera")
@@ -175,12 +175,14 @@ if picture_path:
175
  # Create DataLoader for Webcam Image
176
  webcam_ds = dataset_prod_obj.create_dataset(picture_path)
177
  webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
178
-
179
-
180
- prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
181
- predictions = torch.cat(prediction, 0).to('cpu')
182
- match_idx = torch.argmin(predictions)
183
- if predictions[match_idx] <= 0.3:
184
- st.write('Welcome: ',image_paths[match_idx].split('/')[-1].split('.')[0])
185
- else:
186
- st.write("Match not found")
 
 
 
165
  prod_dl = DataLoader(prod_ds, batch_size=BATCH_SIZE)
166
 
167
  # Testing the dataloader
168
+ #prod_inputs = next(iter(prod_dl))
169
+ #st.write(prod_inputs['pixel_values'].shape)
170
 
171
  # Read image from Camera
172
  enable = st.checkbox("Enable camera")
 
175
  # Create DataLoader for Webcam Image
176
  webcam_ds = dataset_prod_obj.create_dataset(picture_path)
177
  webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
178
+
179
+ # Run the predictions
180
+ prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
181
+ predictions = torch.cat(prediction, 0).to('cpu')
182
+ match_idx = torch.argmin(predictions)
183
+
184
+ # Display the results
185
+ if predictions[match_idx] <= 0.3:
186
+ st.write('Welcome: ',image_paths[match_idx].split('/')[-1].split('.')[0])
187
+ else:
188
+ st.write("Match not found")