lxy1122 commited on
Commit
e497225
·
1 Parent(s): d6ae94d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -7,7 +7,7 @@ import torch.nn as nn
7
 
8
 
9
  os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/artist_classes.txt")
10
- os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth")
11
 
12
  #model = torch.hub.load('pytorch/vision:v0.9.0', 'mobilenet_v2', pretrained=False)
13
  #checkpoint = 'https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth'
@@ -15,8 +15,10 @@ os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/m
15
  model = models.mobilenet_v2()
16
  num_ftrs = model.classifier[1].in_features
17
  model.classifier[1] = nn.Linear(num_ftrs, 6)
 
18
  #model = model.to(device)
19
- model.load_state_dict(torch.load('model_weights_mobilenet_v2_valp1trainp2.pth'))
 
20
 
21
  #torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
22
 
 
7
 
8
 
9
  os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/artist_classes.txt")
10
+ #os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth")
11
 
12
  #model = torch.hub.load('pytorch/vision:v0.9.0', 'mobilenet_v2', pretrained=False)
13
  #checkpoint = 'https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth'
 
15
  model = models.mobilenet_v2()
16
  num_ftrs = model.classifier[1].in_features
17
  model.classifier[1] = nn.Linear(num_ftrs, 6)
18
+ device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
19
  #model = model.to(device)
20
+ model.load_state_dict(torch.load('model_weights_mobilenet_v2_valp1trainp2.pth',map_location=device))
21
+ #model.load_state_dict(torch.load('model_weights_mobilenet_v2_valp1trainp2.pth'))
22
 
23
  #torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
24