lime-j commited on
Commit
b2faee1
·
1 Parent(s): 90c861e
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -8,7 +8,17 @@ from models.arch.classifier import PretrainedConvNext
8
  import torchvision.transforms.functional as TF
9
  import spaces
10
 
11
-
 
 
 
 
 
 
 
 
 
 
12
  def align(x1):
13
  h, w = x1.shape[:2]
14
  h, w = h // 32 * 32, w // 32 * 32
@@ -17,17 +27,6 @@ def align(x1):
17
  @spaces.GPU(duration=120)
18
  def predict(img):
19
  with torch.no_grad():
20
- channels = [64, 128, 256, 512]
21
- layers = [2, 2, 4, 2]
22
- num_subnet = 4
23
- net_i = FullNet_NLP(channels, layers, num_subnet, 4,num_classes=1000, drop_path=0,save_memory=True, inter_supv=True, head_init_scale=None,kernel_size=3)
24
- for param in net_i.parameters():
25
- param.data = param.data.to(torch.float16)
26
- net_i.load_state_dict(torch.load('./fp16_check.pt')['icnn']).cuda()
27
- net_c = PretrainedConvNext("convnext_small_in22k")
28
- net_c.load_state_dict(torch.load('./classifier_32.pt')['icnn']).cuda()
29
- net_i.eval()
30
- net_c.eval()
31
  img=align(img)
32
  image_tensor=TF.to_tensor(img).cuda()
33
  image_tensor=image_tensor.unsqueeze(0).cuda()
 
8
  import torchvision.transforms.functional as TF
9
  import spaces
10
 
11
+ channels = [64, 128, 256, 512]
12
+ layers = [2, 2, 4, 2]
13
+ num_subnet = 4
14
+ net_i = FullNet_NLP(channels, layers, num_subnet, 4,num_classes=1000, drop_path=0,save_memory=True, inter_supv=True, head_init_scale=None,kernel_size=3)
15
+ for param in net_i.parameters():
16
+ param.data = param.data.to(torch.float16)
17
+ net_i.load_state_dict(torch.load('./fp16_check.pt')['icnn']).cuda()
18
+ net_c = PretrainedConvNext("convnext_small_in22k")
19
+ net_c.load_state_dict(torch.load('./classifier_32.pt')['icnn']).cuda()
20
+ net_i.eval()
21
+ net_c.eval()
22
  def align(x1):
23
  h, w = x1.shape[:2]
24
  h, w = h // 32 * 32, w // 32 * 32
 
27
  @spaces.GPU(duration=120)
28
  def predict(img):
29
  with torch.no_grad():
 
 
 
 
 
 
 
 
 
 
 
30
  img=align(img)
31
  image_tensor=TF.to_tensor(img).cuda()
32
  image_tensor=image_tensor.unsqueeze(0).cuda()