vobecant
commited on
Commit
·
d429324
1
Parent(s):
10b0c9c
Initial commit.
Browse files- .idea/workspace.xml +9 -3
- app.py +10 -3
.idea/workspace.xml
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
<project version="4">
|
| 3 |
<component name="ChangeListManager">
|
| 4 |
<list default="true" id="5dd22f22-8223-4d55-99f9-57d1e00622d7" name="Default Changelist" comment="Initial commit.">
|
| 5 |
-
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
| 6 |
<change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
|
| 7 |
</list>
|
| 8 |
<option name="SHOW_DIALOG" value="false" />
|
|
@@ -52,7 +51,7 @@
|
|
| 52 |
<option name="number" value="Default" />
|
| 53 |
<option name="presentableId" value="Default" />
|
| 54 |
<updated>1647350746642</updated>
|
| 55 |
-
<workItem from="1647350750956" duration="
|
| 56 |
</task>
|
| 57 |
<task id="LOCAL-00001" summary="Initial commit.">
|
| 58 |
<created>1647352693910</created>
|
|
@@ -369,7 +368,14 @@
|
|
| 369 |
<option name="project" value="LOCAL" />
|
| 370 |
<updated>1647362439904</updated>
|
| 371 |
</task>
|
| 372 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
<servers />
|
| 374 |
</component>
|
| 375 |
<component name="TypeScriptGeneratedFilesManager">
|
|
|
|
| 2 |
<project version="4">
|
| 3 |
<component name="ChangeListManager">
|
| 4 |
<list default="true" id="5dd22f22-8223-4d55-99f9-57d1e00622d7" name="Default Changelist" comment="Initial commit.">
|
|
|
|
| 5 |
<change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
|
| 6 |
</list>
|
| 7 |
<option name="SHOW_DIALOG" value="false" />
|
|
|
|
| 51 |
<option name="number" value="Default" />
|
| 52 |
<option name="presentableId" value="Default" />
|
| 53 |
<updated>1647350746642</updated>
|
| 54 |
+
<workItem from="1647350750956" duration="12425000" />
|
| 55 |
</task>
|
| 56 |
<task id="LOCAL-00001" summary="Initial commit.">
|
| 57 |
<created>1647352693910</created>
|
|
|
|
| 368 |
<option name="project" value="LOCAL" />
|
| 369 |
<updated>1647362439904</updated>
|
| 370 |
</task>
|
| 371 |
+
<task id="LOCAL-00046" summary="Initial commit.">
|
| 372 |
+
<created>1647363375249</created>
|
| 373 |
+
<option name="number" value="00046" />
|
| 374 |
+
<option name="presentableId" value="LOCAL-00046" />
|
| 375 |
+
<option name="project" value="LOCAL" />
|
| 376 |
+
<updated>1647363375249</updated>
|
| 377 |
+
</task>
|
| 378 |
+
<option name="localTasksCounter" value="47" />
|
| 379 |
<servers />
|
| 380 |
</component>
|
| 381 |
<component name="TypeScriptGeneratedFilesManager">
|
app.py
CHANGED
|
@@ -14,6 +14,12 @@ from segmenter_model.utils import colorize_one, map2cs
|
|
| 14 |
# WEIGHTS = './weights/segmenter.pth
|
| 15 |
WEIGHTS = './weights/segmenter_nusc.pth'
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def download_file_from_google_drive(destination=WEIGHTS):
|
| 19 |
id = '1v6_d2KHzRROsjb_cgxU7jvmnGVDXeBia'
|
|
@@ -132,9 +138,9 @@ model, window_size, window_stride = create_model()
|
|
| 132 |
|
| 133 |
|
| 134 |
def predict(input_img):
|
| 135 |
-
|
| 136 |
transform = get_transformations()
|
| 137 |
-
input_img = transform(
|
| 138 |
input_img = torch.unsqueeze(input_img, 0)
|
| 139 |
|
| 140 |
print('Loaded and prepaded image.')
|
|
@@ -152,8 +158,9 @@ def predict(input_img):
|
|
| 152 |
|
| 153 |
# drawing_pseudo = transforms.ToPILImage()(drawing_pseudo)
|
| 154 |
drawing_cs = transforms.ToPILImage()(drawing_cs)
|
|
|
|
| 155 |
# return drawing_pseudo, drawing_cs
|
| 156 |
-
return
|
| 157 |
|
| 158 |
|
| 159 |
title = "Drive&Segment"
|
|
|
|
| 14 |
# WEIGHTS = './weights/segmenter.pth
|
| 15 |
WEIGHTS = './weights/segmenter_nusc.pth'
|
| 16 |
|
| 17 |
+
def blend_images(bg, fg, alpha=0.3):
|
| 18 |
+
fg = fg.convert('RGBA')
|
| 19 |
+
bg = bg.convert('RGBA')
|
| 20 |
+
blended = Image.blend(bg, fg, alpha=alpha)
|
| 21 |
+
|
| 22 |
+
return blended
|
| 23 |
|
| 24 |
def download_file_from_google_drive(destination=WEIGHTS):
|
| 25 |
id = '1v6_d2KHzRROsjb_cgxU7jvmnGVDXeBia'
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
def predict(input_img):
|
| 141 |
+
input_img_pil = Image.open(input_img)
|
| 142 |
transform = get_transformations()
|
| 143 |
+
input_img = transform(input_img_pil)
|
| 144 |
input_img = torch.unsqueeze(input_img, 0)
|
| 145 |
|
| 146 |
print('Loaded and prepaded image.')
|
|
|
|
| 158 |
|
| 159 |
# drawing_pseudo = transforms.ToPILImage()(drawing_pseudo)
|
| 160 |
drawing_cs = transforms.ToPILImage()(drawing_cs)
|
| 161 |
+
drawing_cs_blend = blend_images(input_img_pil, drawing_cs)
|
| 162 |
# return drawing_pseudo, drawing_cs
|
| 163 |
+
return drawing_cs_blend
|
| 164 |
|
| 165 |
|
| 166 |
title = "Drive&Segment"
|