Object detection app
Browse files- app.py +6 -1
- saved_model +0 -3
app.py
CHANGED
@@ -19,13 +19,18 @@ from get_output import visualize_output
|
|
19 |
# Use GPU if available
|
20 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
21 |
|
22 |
-
# Initialize models
|
23 |
vit = timm.create_model('vit_base_patch16_224', pretrained=True, num_classes=0, global_pool='').to(device)
|
24 |
tokenizer = RobertaTokenizer.from_pretrained('roberta-base', truncation=True, do_lower_case=True)
|
25 |
roberta = RobertaModel.from_pretrained("roberta-base")
|
26 |
model = Model(vit, roberta, tokenizer, device).to(device)
|
27 |
model.eval()
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
config = resolve_data_config({}, model=vit)
|
30 |
config['no_aug'] = True
|
31 |
config['interpolation'] = 'bilinear'
|
|
|
19 |
# Use GPU if available
|
20 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
21 |
|
22 |
+
# Initialize used pretrained models
|
23 |
vit = timm.create_model('vit_base_patch16_224', pretrained=True, num_classes=0, global_pool='').to(device)
|
24 |
tokenizer = RobertaTokenizer.from_pretrained('roberta-base', truncation=True, do_lower_case=True)
|
25 |
roberta = RobertaModel.from_pretrained("roberta-base")
|
26 |
model = Model(vit, roberta, tokenizer, device).to(device)
|
27 |
model.eval()
|
28 |
|
29 |
+
# Initialize trained model
|
30 |
+
state = torch.load(target_dir)
|
31 |
+
model.load_state_dict(state['val_model_dict'])
|
32 |
+
|
33 |
+
# Transform for input image
|
34 |
config = resolve_data_config({}, model=vit)
|
35 |
config['no_aug'] = True
|
36 |
config['interpolation'] = 'bilinear'
|
saved_model
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:2428efe9822882f6b4e42733bdbe18a2f7b765eee6bc462f01267691cc86ab80
|
3 |
-
size 2389229209
|
|
|
|
|
|
|
|