vobecant
commited on
Commit
·
02b6361
1
Parent(s):
059c85a
Initial commit.
Browse files- .idea/workspace.xml +55 -10
- app.py +10 -8
- weights/segmenter_nusc.pth_variant.yml +3 -3
- weights/segmenter_nusc.pth_variant_old.yml +36 -0
.idea/workspace.xml
CHANGED
|
@@ -2,8 +2,10 @@
|
|
| 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 afterPath="$PROJECT_DIR$/
|
|
|
|
| 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" />
|
| 9 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -44,6 +46,30 @@
|
|
| 44 |
<recent name="$PROJECT_DIR$/examples" />
|
| 45 |
</key>
|
| 46 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
| 48 |
<component name="TaskManager">
|
| 49 |
<task active="true" id="Default" summary="Default task">
|
|
@@ -52,14 +78,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-00006" summary="Initial commit.">
|
| 58 |
-
<created>1647354226094</created>
|
| 59 |
-
<option name="number" value="00006" />
|
| 60 |
-
<option name="presentableId" value="LOCAL-00006" />
|
| 61 |
-
<option name="project" value="LOCAL" />
|
| 62 |
-
<updated>1647354226094</updated>
|
| 63 |
</task>
|
| 64 |
<task id="LOCAL-00007" summary="Initial commit.">
|
| 65 |
<created>1647355534027</created>
|
|
@@ -397,7 +416,14 @@
|
|
| 397 |
<option name="project" value="LOCAL" />
|
| 398 |
<updated>1647366052086</updated>
|
| 399 |
</task>
|
| 400 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
<servers />
|
| 402 |
</component>
|
| 403 |
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -419,4 +445,23 @@
|
|
| 419 |
<MESSAGE value="Initial commit." />
|
| 420 |
<option name="LAST_COMMIT_MESSAGE" value="Initial commit." />
|
| 421 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
</project>
|
|
|
|
| 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 afterPath="$PROJECT_DIR$/weights/segmenter_nusc.pth_variant_old.yml" afterDir="false" />
|
| 6 |
+
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
| 7 |
<change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
|
| 8 |
+
<change beforePath="$PROJECT_DIR$/weights/segmenter_nusc.pth_variant.yml" beforeDir="false" afterPath="$PROJECT_DIR$/weights/segmenter_nusc.pth_variant.yml" afterDir="false" />
|
| 9 |
</list>
|
| 10 |
<option name="SHOW_DIALOG" value="false" />
|
| 11 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
|
|
| 46 |
<recent name="$PROJECT_DIR$/examples" />
|
| 47 |
</key>
|
| 48 |
</component>
|
| 49 |
+
<component name="RunManager">
|
| 50 |
+
<configuration name="app" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
| 51 |
+
<module name="DaS" />
|
| 52 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 53 |
+
<option name="PARENT_ENVS" value="true" />
|
| 54 |
+
<envs>
|
| 55 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
| 56 |
+
</envs>
|
| 57 |
+
<option name="SDK_HOME" value="$USER_HOME$/miniconda3/envs/pytorch/bin/python3" />
|
| 58 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
| 59 |
+
<option name="IS_MODULE_SDK" value="false" />
|
| 60 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 61 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 62 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 63 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app.py" />
|
| 64 |
+
<option name="PARAMETERS" value="" />
|
| 65 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
| 66 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
| 67 |
+
<option name="MODULE_MODE" value="false" />
|
| 68 |
+
<option name="REDIRECT_INPUT" value="false" />
|
| 69 |
+
<option name="INPUT_FILE" value="" />
|
| 70 |
+
<method v="2" />
|
| 71 |
+
</configuration>
|
| 72 |
+
</component>
|
| 73 |
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
| 74 |
<component name="TaskManager">
|
| 75 |
<task active="true" id="Default" summary="Default task">
|
|
|
|
| 78 |
<option name="number" value="Default" />
|
| 79 |
<option name="presentableId" value="Default" />
|
| 80 |
<updated>1647350746642</updated>
|
| 81 |
+
<workItem from="1647350750956" duration="15168000" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
</task>
|
| 83 |
<task id="LOCAL-00007" summary="Initial commit.">
|
| 84 |
<created>1647355534027</created>
|
|
|
|
| 416 |
<option name="project" value="LOCAL" />
|
| 417 |
<updated>1647366052086</updated>
|
| 418 |
</task>
|
| 419 |
+
<task id="LOCAL-00055" summary="Initial commit.">
|
| 420 |
+
<created>1647366376267</created>
|
| 421 |
+
<option name="number" value="00055" />
|
| 422 |
+
<option name="presentableId" value="LOCAL-00055" />
|
| 423 |
+
<option name="project" value="LOCAL" />
|
| 424 |
+
<updated>1647366376267</updated>
|
| 425 |
+
</task>
|
| 426 |
+
<option name="localTasksCounter" value="56" />
|
| 427 |
<servers />
|
| 428 |
</component>
|
| 429 |
<component name="TypeScriptGeneratedFilesManager">
|
|
|
|
| 445 |
<MESSAGE value="Initial commit." />
|
| 446 |
<option name="LAST_COMMIT_MESSAGE" value="Initial commit." />
|
| 447 |
</component>
|
| 448 |
+
<component name="XDebuggerManager">
|
| 449 |
+
<breakpoint-manager>
|
| 450 |
+
<breakpoints>
|
| 451 |
+
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
| 452 |
+
<url>file://$PROJECT_DIR$/app.py</url>
|
| 453 |
+
<line>66</line>
|
| 454 |
+
<option name="timeStamp" value="2" />
|
| 455 |
+
</line-breakpoint>
|
| 456 |
+
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
| 457 |
+
<url>file://$PROJECT_DIR$/segmenter_model/utils.py</url>
|
| 458 |
+
<line>393</line>
|
| 459 |
+
<option name="timeStamp" value="3" />
|
| 460 |
+
</line-breakpoint>
|
| 461 |
+
</breakpoints>
|
| 462 |
+
</breakpoint-manager>
|
| 463 |
+
</component>
|
| 464 |
+
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 465 |
+
<SUITE FILE_PATH="coverage/DaS$app.coverage" NAME="app Coverage Results" MODIFIED="1647368417514" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 466 |
+
</component>
|
| 467 |
</project>
|
app.py
CHANGED
|
@@ -108,6 +108,7 @@ def create_model(resnet=False):
|
|
| 108 |
# TODO: parse hyperparameters
|
| 109 |
window_size = variant['inference_kwargs']["window_size"]
|
| 110 |
window_stride = variant['inference_kwargs']["window_stride"]
|
|
|
|
| 111 |
|
| 112 |
net_kwargs = variant["net_kwargs"]
|
| 113 |
if not resnet:
|
|
@@ -126,19 +127,20 @@ def create_model(resnet=False):
|
|
| 126 |
|
| 127 |
model.eval()
|
| 128 |
|
| 129 |
-
return model, window_size, window_stride
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
def get_transformations():
|
| 133 |
return transforms.Compose([
|
| 134 |
transforms.ToTensor(),
|
|
|
|
| 135 |
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
|
| 136 |
|
| 137 |
|
| 138 |
-
download_weights()
|
| 139 |
-
model, window_size, window_stride = create_model()
|
| 140 |
-
|
| 141 |
-
|
| 142 |
def predict(input_img):
|
| 143 |
input_img_pil = Image.open(input_img)
|
| 144 |
transform = get_transformations()
|
|
@@ -159,7 +161,7 @@ def predict(input_img):
|
|
| 159 |
print('CS colors done.')
|
| 160 |
|
| 161 |
# drawing_pseudo = transforms.ToPILImage()(drawing_pseudo)
|
| 162 |
-
drawing_cs = transforms.ToPILImage()(drawing_cs)
|
| 163 |
drawing_cs_blend = blend_images(input_img_pil, drawing_cs)
|
| 164 |
# return drawing_pseudo, drawing_cs
|
| 165 |
return drawing_cs_blend
|
|
@@ -168,9 +170,9 @@ def predict(input_img):
|
|
| 168 |
title = "Drive&Segment"
|
| 169 |
description = 'Gradio Demo accompanying paper "Drive&Segment: Unsupervised Semantic Segmentation of Urban Scenes via Cross-modal Distillation"\nBecause of the CPU-only inference, it might take up to 20s for large images.'
|
| 170 |
# article = "<p style='text-align: center'><a href='TODO' target='_blank'>Project Page</a> | <a href='codelink' target='_blank'>Github</a></p>"
|
| 171 |
-
examples = ['examples/img5.jpeg','examples/100.jpeg', 'examples/39076.jpeg', 'examples/img1.jpg']
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
iface = gr.Interface(predict, gr.inputs.Image(type='filepath'), "image", title=title, description=description,
|
| 176 |
examples=examples)
|
|
|
|
| 108 |
# TODO: parse hyperparameters
|
| 109 |
window_size = variant['inference_kwargs']["window_size"]
|
| 110 |
window_stride = variant['inference_kwargs']["window_stride"]
|
| 111 |
+
im_size = variant['inference_kwargs']["im_size"]
|
| 112 |
|
| 113 |
net_kwargs = variant["net_kwargs"]
|
| 114 |
if not resnet:
|
|
|
|
| 127 |
|
| 128 |
model.eval()
|
| 129 |
|
| 130 |
+
return model, window_size, window_stride, im_size
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
download_weights()
|
| 134 |
+
model, window_size, window_stride, im_size = create_model()
|
| 135 |
|
| 136 |
|
| 137 |
def get_transformations():
|
| 138 |
return transforms.Compose([
|
| 139 |
transforms.ToTensor(),
|
| 140 |
+
transforms.Resize(im_size),
|
| 141 |
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
|
| 142 |
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
def predict(input_img):
|
| 145 |
input_img_pil = Image.open(input_img)
|
| 146 |
transform = get_transformations()
|
|
|
|
| 161 |
print('CS colors done.')
|
| 162 |
|
| 163 |
# drawing_pseudo = transforms.ToPILImage()(drawing_pseudo)
|
| 164 |
+
drawing_cs = transforms.ToPILImage()(drawing_cs).resize(input_img_pil.size)
|
| 165 |
drawing_cs_blend = blend_images(input_img_pil, drawing_cs)
|
| 166 |
# return drawing_pseudo, drawing_cs
|
| 167 |
return drawing_cs_blend
|
|
|
|
| 170 |
title = "Drive&Segment"
|
| 171 |
description = 'Gradio Demo accompanying paper "Drive&Segment: Unsupervised Semantic Segmentation of Urban Scenes via Cross-modal Distillation"\nBecause of the CPU-only inference, it might take up to 20s for large images.'
|
| 172 |
# article = "<p style='text-align: center'><a href='TODO' target='_blank'>Project Page</a> | <a href='codelink' target='_blank'>Github</a></p>"
|
| 173 |
+
examples = ['examples/img5.jpeg', 'examples/100.jpeg', 'examples/39076.jpeg', 'examples/img1.jpg']
|
| 174 |
|
| 175 |
+
predict(examples[0])
|
| 176 |
|
| 177 |
iface = gr.Interface(predict, gr.inputs.Image(type='filepath'), "image", title=title, description=description,
|
| 178 |
examples=examples)
|
weights/segmenter_nusc.pth_variant.yml
CHANGED
|
@@ -3,9 +3,9 @@ dataset_kwargs:
|
|
| 3 |
window_stride: 384
|
| 4 |
debug: false
|
| 5 |
inference_kwargs:
|
| 6 |
-
im_size:
|
| 7 |
-
window_size:
|
| 8 |
-
window_stride:
|
| 9 |
net_kwargs:
|
| 10 |
backbone: dino_vits16
|
| 11 |
d_model: 384
|
|
|
|
| 3 |
window_stride: 384
|
| 4 |
debug: false
|
| 5 |
inference_kwargs:
|
| 6 |
+
im_size: 512
|
| 7 |
+
window_size: 256
|
| 8 |
+
window_stride: 128
|
| 9 |
net_kwargs:
|
| 10 |
backbone: dino_vits16
|
| 11 |
d_model: 384
|
weights/segmenter_nusc.pth_variant_old.yml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dataset_kwargs:
|
| 2 |
+
window_size: 512
|
| 3 |
+
window_stride: 384
|
| 4 |
+
debug: false
|
| 5 |
+
inference_kwargs:
|
| 6 |
+
im_size: 1024
|
| 7 |
+
window_size: 512
|
| 8 |
+
window_stride: 256
|
| 9 |
+
net_kwargs:
|
| 10 |
+
backbone: dino_vits16
|
| 11 |
+
d_model: 384
|
| 12 |
+
decoder:
|
| 13 |
+
drop_path_rate: 0.0
|
| 14 |
+
dropout: 0.1
|
| 15 |
+
n_cls: 31
|
| 16 |
+
n_layers: 1
|
| 17 |
+
name: mask_transformer
|
| 18 |
+
distilled: false
|
| 19 |
+
drop_path_rate: 0.1
|
| 20 |
+
dropout: 0.0
|
| 21 |
+
image_size: !!python/tuple
|
| 22 |
+
- 256
|
| 23 |
+
- 256
|
| 24 |
+
n_cls: 31
|
| 25 |
+
n_heads: 3
|
| 26 |
+
n_layers: 12
|
| 27 |
+
normalization: deit
|
| 28 |
+
patch_size: 16
|
| 29 |
+
val_dataset_kwargs:
|
| 30 |
+
batch_size: 1
|
| 31 |
+
crop_size: 512
|
| 32 |
+
dataset: cityscapes
|
| 33 |
+
image_size: 1024
|
| 34 |
+
normalization: deit
|
| 35 |
+
num_workers: 10
|
| 36 |
+
split: val
|