PushkarA07 commited on
Commit
27e311e
·
1 Parent(s): 61ffd48

Update web_app.py

Browse files
Files changed (1) hide show
  1. web_app.py +0 -15
web_app.py CHANGED
@@ -4,9 +4,6 @@ from fastai.vision.learner import create_body
4
  import streamlit as st
5
  from PIL import Image
6
  import cv2 as cv
7
-
8
- # ---------Backend--------------------------------------------------------------
9
-
10
  import os
11
  import glob
12
  import time
@@ -58,8 +55,6 @@ class ColorizationDataset(Dataset):
58
  def __len__(self):
59
  return len(self.paths)
60
 
61
-
62
- # A handy function to make our dataloaders
63
  def make_dataloaders(batch_size=16, n_workers=4, pin_memory=True, **kwargs):
64
  dataset = ColorizationDataset(**kwargs)
65
  dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=n_workers,
@@ -313,10 +308,6 @@ def update_losses(model, loss_meter_dict, count):
313
 
314
 
315
  def lab_to_rgb(L, ab):
316
- """
317
- Takes a batch of images
318
- """
319
-
320
  L = (L + 1.) * 50.
321
  ab = ab * 110.
322
  Lab = torch.cat([L, ab], dim=1).permute(0, 2, 3, 1).cpu().numpy()
@@ -352,10 +343,6 @@ def log_results(loss_meter_dict):
352
  for loss_name, loss_meter in loss_meter_dict.items():
353
  print(f"{loss_name}: {loss_meter.avg:.5f}")
354
 
355
-
356
- # pip install fastai==2.4
357
-
358
-
359
  def build_res_unet(n_input=1, n_output=2, size=256):
360
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
361
  body = create_body(resnet18(), pretrained=True, n_in=n_input, cut=-2)
@@ -388,8 +375,6 @@ class MyDataset(torch.utils.data.Dataset):
388
  ab = img_lab[[1, 2], ...] / 110.
389
  return {'L': L, 'ab': ab}
390
 
391
-
392
- # A handy function to make our dataloaders
393
  def make_dataloaders2(batch_size=16, n_workers=4, pin_memory=True, **kwargs):
394
  dataset = MyDataset(**kwargs)
395
  dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=n_workers,
 
4
  import streamlit as st
5
  from PIL import Image
6
  import cv2 as cv
 
 
 
7
  import os
8
  import glob
9
  import time
 
55
  def __len__(self):
56
  return len(self.paths)
57
 
 
 
58
  def make_dataloaders(batch_size=16, n_workers=4, pin_memory=True, **kwargs):
59
  dataset = ColorizationDataset(**kwargs)
60
  dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=n_workers,
 
308
 
309
 
310
  def lab_to_rgb(L, ab):
 
 
 
 
311
  L = (L + 1.) * 50.
312
  ab = ab * 110.
313
  Lab = torch.cat([L, ab], dim=1).permute(0, 2, 3, 1).cpu().numpy()
 
343
  for loss_name, loss_meter in loss_meter_dict.items():
344
  print(f"{loss_name}: {loss_meter.avg:.5f}")
345
 
 
 
 
 
346
  def build_res_unet(n_input=1, n_output=2, size=256):
347
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
348
  body = create_body(resnet18(), pretrained=True, n_in=n_input, cut=-2)
 
375
  ab = img_lab[[1, 2], ...] / 110.
376
  return {'L': L, 'ab': ab}
377
 
 
 
378
  def make_dataloaders2(batch_size=16, n_workers=4, pin_memory=True, **kwargs):
379
  dataset = MyDataset(**kwargs)
380
  dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=n_workers,