adowu commited on
Commit
2cb794f
·
verified ·
1 Parent(s): f3068c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -8,12 +8,15 @@ import matplotlib.pyplot as plt
8
  from pathlib import Path
9
 
10
  # ================================================
11
- # REQUIRED STUB CLASSES / FUNCTIONS FOR LOADING
 
12
  # ================================================
13
 
14
- def _inner(*args, **kwargs):
15
- return None
 
16
 
 
17
  class ReflectionLayer(nn.Module):
18
  def __init__(self): super().__init__()
19
  def forward(self, x): return x
@@ -49,10 +52,10 @@ learner = from_pretrained_fastai(REPO_ID)
49
  # ================================================
50
 
51
  def infer(img):
52
- # Convert to PILImage if needed
53
  if not isinstance(img, PILImage):
54
  img = PILImage.create(img)
55
-
56
  pred = learner.predict(img)
57
  image = pred[0].numpy()
58
  image = image.transpose((1, 2, 0)) # CHW -> HWC
 
8
  from pathlib import Path
9
 
10
  # ================================================
11
+ # STUBS FOR CUSTOM CLASSES / FUNCTIONS
12
+ # These match all custom classes used in the model
13
  # ================================================
14
 
15
+ # Functions
16
+ def _inner(*args, **kwargs): return None
17
+ def style_loss(*args, **kwargs): return None
18
 
19
+ # Layers
20
  class ReflectionLayer(nn.Module):
21
  def __init__(self): super().__init__()
22
  def forward(self, x): return x
 
52
  # ================================================
53
 
54
  def infer(img):
55
+ # Ensure PILImage
56
  if not isinstance(img, PILImage):
57
  img = PILImage.create(img)
58
+
59
  pred = learner.predict(img)
60
  image = pred[0].numpy()
61
  image = image.transpose((1, 2, 0)) # CHW -> HWC