Sanket commited on
Commit ·
eb7fd36
1
Parent(s): 5f74f5a
to 1080p
Browse files
app.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
-
import
|
| 2 |
import torch
|
| 3 |
import torch.nn as nn
|
| 4 |
-
import gradio as gr
|
| 5 |
-
from PIL import Image
|
| 6 |
import torchvision.transforms as transforms
|
|
|
|
| 7 |
|
| 8 |
norm_layer = nn.InstanceNorm2d
|
| 9 |
|
|
@@ -93,7 +92,7 @@ model2.eval()
|
|
| 93 |
|
| 94 |
def predict(input_img, ver):
|
| 95 |
input_img = Image.open(input_img)
|
| 96 |
-
transform = transforms.Compose([transforms.Resize(
|
| 97 |
input_img = transform(input_img)
|
| 98 |
input_img = torch.unsqueeze(input_img, 0)
|
| 99 |
|
|
@@ -103,7 +102,7 @@ def predict(input_img, ver):
|
|
| 103 |
drawing = model2(input_img)[0].detach()
|
| 104 |
else:
|
| 105 |
drawing = model1(input_img)[0].detach()
|
| 106 |
-
|
| 107 |
drawing = transforms.ToPILImage()(drawing)
|
| 108 |
return drawing
|
| 109 |
|
|
@@ -123,4 +122,4 @@ iface = gr.Interface(predict, [gr.inputs.Image(type='filepath'),
|
|
| 123 |
gr.inputs.Radio(['Complex Lines','Simple Lines'], type="value", default='Simple Lines', label='version')],
|
| 124 |
gr.outputs.Image(type="pil"), title=title,examples=examples)
|
| 125 |
|
| 126 |
-
iface.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import torch
|
| 3 |
import torch.nn as nn
|
|
|
|
|
|
|
| 4 |
import torchvision.transforms as transforms
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
norm_layer = nn.InstanceNorm2d
|
| 8 |
|
|
|
|
| 92 |
|
| 93 |
def predict(input_img, ver):
|
| 94 |
input_img = Image.open(input_img)
|
| 95 |
+
transform = transforms.Compose([transforms.Resize(1080, Image.BICUBIC), transforms.ToTensor()])
|
| 96 |
input_img = transform(input_img)
|
| 97 |
input_img = torch.unsqueeze(input_img, 0)
|
| 98 |
|
|
|
|
| 102 |
drawing = model2(input_img)[0].detach()
|
| 103 |
else:
|
| 104 |
drawing = model1(input_img)[0].detach()
|
| 105 |
+
|
| 106 |
drawing = transforms.ToPILImage()(drawing)
|
| 107 |
return drawing
|
| 108 |
|
|
|
|
| 122 |
gr.inputs.Radio(['Complex Lines','Simple Lines'], type="value", default='Simple Lines', label='version')],
|
| 123 |
gr.outputs.Image(type="pil"), title=title,examples=examples)
|
| 124 |
|
| 125 |
+
iface.launch()
|