Ahsen Khaliq commited on
Commit
d57300d
1 Parent(s): d627a04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -13,6 +13,35 @@ from tqdm import tqdm, trange
13
  import skimage.io as io
14
  import PIL.Image
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  class MLP(nn.Module):
17
 
18
  def forward(self, x: T) -> T:
 
13
  import skimage.io as io
14
  import PIL.Image
15
 
16
+ N = type(None)
17
+ V = np.array
18
+ ARRAY = np.ndarray
19
+ ARRAYS = Union[Tuple[ARRAY, ...], List[ARRAY]]
20
+ VS = Union[Tuple[V, ...], List[V]]
21
+ VN = Union[V, N]
22
+ VNS = Union[VS, N]
23
+ T = torch.Tensor
24
+ TS = Union[Tuple[T, ...], List[T]]
25
+ TN = Optional[T]
26
+ TNS = Union[Tuple[TN, ...], List[TN]]
27
+ TSN = Optional[TS]
28
+ TA = Union[T, ARRAY]
29
+
30
+
31
+ D = torch.device
32
+ CPU = torch.device('cpu')
33
+
34
+ model_path = 'model_wieghts.pt'
35
+
36
+ def get_device(device_id: int) -> D:
37
+ if not torch.cuda.is_available():
38
+ return CPU
39
+ device_id = min(torch.cuda.device_count() - 1, device_id)
40
+ return torch.device(f'cuda:{device_id}')
41
+
42
+
43
+ CUDA = get_device
44
+
45
  class MLP(nn.Module):
46
 
47
  def forward(self, x: T) -> T: