Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,12 +8,15 @@ import matplotlib.pyplot as plt
|
|
| 8 |
from pathlib import Path
|
| 9 |
|
| 10 |
# ================================================
|
| 11 |
-
#
|
|
|
|
| 12 |
# ================================================
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 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 |
-
#
|
| 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
|