Caroline Mai Chan
commited on
Commit
·
bf3b2c9
1
Parent(s):
41bee7b
add filepath
Browse files
app.py
CHANGED
@@ -60,12 +60,14 @@ class Generator(nn.Module):
|
|
60 |
|
61 |
return out
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
def
|
68 |
-
|
|
|
|
|
69 |
sepia_filter = np.array(
|
70 |
[[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]
|
71 |
)
|
@@ -74,6 +76,6 @@ def sepia(input_img):
|
|
74 |
return sepia_img
|
75 |
|
76 |
|
77 |
-
iface = gr.Interface(sepia, gr.inputs.Image(
|
78 |
|
79 |
iface.launch()
|
|
|
60 |
|
61 |
return out
|
62 |
|
63 |
+
model = Generator(3, 1, 3)
|
64 |
+
model.load_state_dict(torch.load('model.pth'))
|
65 |
+
model.eval()
|
66 |
|
67 |
+
def predict(input_img):
|
68 |
+
input_img = Image.open(input_img)
|
69 |
+
ratio = input_img.size[1] / 256.0
|
70 |
+
input_img = input_img.resize((int(ratio*input_img.size[0]),256), Image.ANTIALIAS)
|
71 |
sepia_filter = np.array(
|
72 |
[[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]
|
73 |
)
|
|
|
76 |
return sepia_img
|
77 |
|
78 |
|
79 |
+
iface = gr.Interface(sepia, gr.inputs.Image(type='filepath'), "image")
|
80 |
|
81 |
iface.launch()
|