akiyamasho commited on
Commit
0055c8e
1 Parent(s): 0df0208

MAINT: dev setup and GPU

Browse files
Files changed (2) hide show
  1. app.py +5 -4
  2. requirements_dev.txt +3 -1
app.py CHANGED
@@ -50,7 +50,7 @@ hosoda_model.eval()
50
  miyazaki_model.eval()
51
  kon_model.eval()
52
 
53
- disable_gpu = True
54
 
55
 
56
  def get_model(style):
@@ -72,6 +72,7 @@ def get_model(style):
72
  def adjust_image_for_model(img):
73
  logger.info(f"Image Height: {img.height}, Image Width: {img.width}")
74
  if img.height > MAX_DIMENSION or img.width > MAX_DIMENSION:
 
75
  img.thumbnail((MAX_DIMENSION, MAX_DIMENSION), Image.ANTIALIAS)
76
 
77
  return img
@@ -89,10 +90,10 @@ def inference(img, style):
89
  # preprocess, (-1, 1)
90
  input_image = -1 + 2 * input_image
91
 
92
- if disable_gpu:
93
- input_image = Variable(input_image).float()
94
- else:
95
  input_image = Variable(input_image).cuda()
 
 
96
 
97
  # forward
98
  model = get_model(style)
 
50
  miyazaki_model.eval()
51
  kon_model.eval()
52
 
53
+ enable_gpu = torch.cuda.is_available()
54
 
55
 
56
  def get_model(style):
 
72
  def adjust_image_for_model(img):
73
  logger.info(f"Image Height: {img.height}, Image Width: {img.width}")
74
  if img.height > MAX_DIMENSION or img.width > MAX_DIMENSION:
75
+ logger.info(f"Dimensions too large. Resizing to {MAX_DIMENSION}px.")
76
  img.thumbnail((MAX_DIMENSION, MAX_DIMENSION), Image.ANTIALIAS)
77
 
78
  return img
 
90
  # preprocess, (-1, 1)
91
  input_image = -1 + 2 * input_image
92
 
93
+ if enable_gpu:
 
 
94
  input_image = Variable(input_image).cuda()
95
+ else:
96
+ input_image = Variable(input_image).float()
97
 
98
  # forward
99
  model = get_model(style)
requirements_dev.txt CHANGED
@@ -1,3 +1,5 @@
1
  -r requirements.txt
2
  black==21.12b0
3
- flake8==4.0.1
 
 
 
1
  -r requirements.txt
2
  black==21.12b0
3
+ flake8==4.0.1
4
+ gradio==2.9.1
5
+ jinja2==3.1.1