vobecant
commited on
Commit
•
bad7981
1
Parent(s):
02b6361
Initial commit.
Browse files- .idea/workspace.xml +9 -11
- app.py +12 -6
.idea/workspace.xml
CHANGED
@@ -2,10 +2,8 @@
|
|
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" />
|
@@ -78,14 +76,7 @@
|
|
78 |
<option name="number" value="Default" />
|
79 |
<option name="presentableId" value="Default" />
|
80 |
<updated>1647350746642</updated>
|
81 |
-
<workItem from="1647350750956" duration="
|
82 |
-
</task>
|
83 |
-
<task id="LOCAL-00007" summary="Initial commit.">
|
84 |
-
<created>1647355534027</created>
|
85 |
-
<option name="number" value="00007" />
|
86 |
-
<option name="presentableId" value="LOCAL-00007" />
|
87 |
-
<option name="project" value="LOCAL" />
|
88 |
-
<updated>1647355534027</updated>
|
89 |
</task>
|
90 |
<task id="LOCAL-00008" summary="Initial commit.">
|
91 |
<created>1647355606191</created>
|
@@ -423,7 +414,14 @@
|
|
423 |
<option name="project" value="LOCAL" />
|
424 |
<updated>1647366376267</updated>
|
425 |
</task>
|
426 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
<servers />
|
428 |
</component>
|
429 |
<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$/.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" />
|
9 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
|
76 |
<option name="number" value="Default" />
|
77 |
<option name="presentableId" value="Default" />
|
78 |
<updated>1647350746642</updated>
|
79 |
+
<workItem from="1647350750956" duration="15638000" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
</task>
|
81 |
<task id="LOCAL-00008" summary="Initial commit.">
|
82 |
<created>1647355606191</created>
|
|
|
414 |
<option name="project" value="LOCAL" />
|
415 |
<updated>1647366376267</updated>
|
416 |
</task>
|
417 |
+
<task id="LOCAL-00056" summary="Initial commit.">
|
418 |
+
<created>1647368703888</created>
|
419 |
+
<option name="number" value="00056" />
|
420 |
+
<option name="presentableId" value="LOCAL-00056" />
|
421 |
+
<option name="project" value="LOCAL" />
|
422 |
+
<updated>1647368703888</updated>
|
423 |
+
</task>
|
424 |
+
<option name="localTasksCounter" value="57" />
|
425 |
<servers />
|
426 |
</component>
|
427 |
<component name="TypeScriptGeneratedFilesManager">
|
app.py
CHANGED
@@ -141,7 +141,7 @@ def get_transformations():
|
|
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()
|
147 |
input_img = transform(input_img_pil)
|
@@ -163,18 +163,24 @@ def predict(input_img):
|
|
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 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
|
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'), "
|
|
|
178 |
examples=examples)
|
179 |
|
180 |
iface.launch(debug=True, show_error=True)
|
|
|
141 |
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
|
142 |
|
143 |
|
144 |
+
def predict(input_img, cs_mapping):
|
145 |
input_img_pil = Image.open(input_img)
|
146 |
transform = get_transformations()
|
147 |
input_img = transform(input_img_pil)
|
|
|
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 |
+
|
167 |
+
if cs_mapping:
|
168 |
+
drawing = drawing_cs
|
169 |
+
else:
|
170 |
+
drawing = drawing_pseudo
|
171 |
+
|
172 |
+
return drawing
|
173 |
|
174 |
|
175 |
title = "Drive&Segment"
|
176 |
+
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.\nRight now, I use the Segmenter model trained on nuScenes and with 256x256 patches (for the sake of speed).'
|
177 |
# article = "<p style='text-align: center'><a href='TODO' target='_blank'>Project Page</a> | <a href='codelink' target='_blank'>Github</a></p>"
|
178 |
examples = ['examples/img5.jpeg', 'examples/100.jpeg', 'examples/39076.jpeg', 'examples/img1.jpg']
|
179 |
|
180 |
+
# predict(examples[0])
|
181 |
|
182 |
+
iface = gr.Interface(predict, [gr.inputs.Image(type='filepath'), gr.inputs.Checkbox(label="Cityscapes mapping")],
|
183 |
+
"image", title=title, description=description,
|
184 |
examples=examples)
|
185 |
|
186 |
iface.launch(debug=True, show_error=True)
|