lime-j commited on
Commit
1eb89b8
·
1 Parent(s): ed34bf2
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -8,19 +8,7 @@ from models.arch.classifier import PretrainedConvNext
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'])
18
- net_i=net_i.to('cuda')
19
- net_c = PretrainedConvNext("convnext_small_in22k")
20
- net_c.load_state_dict(torch.load('./classifier_32.pt')['icnn'])
21
- net_c=net_c.to('cuda')
22
- net_i.eval()
23
- net_c.eval()
24
  def align(x1):
25
  h, w = x1.shape[:2]
26
  h, w = h // 32 * 32, w // 32 * 32
@@ -29,6 +17,19 @@ def align(x1):
29
  @spaces.GPU(duration=120)
30
  def predict(img):
31
  with torch.no_grad():
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  img=align(img)
33
  image_tensor=TF.to_tensor(img)
34
  image_tensor=image_tensor.unsqueeze(0).to("cuda")
 
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
  @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'])
27
+ net_i=net_i.to('cuda')
28
+ net_c = PretrainedConvNext("convnext_small_in22k")
29
+ net_c.load_state_dict(torch.load('./classifier_32.pt')['icnn'])
30
+ net_c=net_c.to('cuda')
31
+ net_i.eval()
32
+ net_c.eval()
33
  img=align(img)
34
  image_tensor=TF.to_tensor(img)
35
  image_tensor=image_tensor.unsqueeze(0).to("cuda")