Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece613-lost
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Spencer Delcore
ece613-lost
Commits
21a8f561
Commit
21a8f561
authored
2 years ago
by
Spencer Delcore
Browse files
Options
Downloads
Patches
Plain Diff
fix bugs in lost for coco finally
parent
de70d078
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
datasets.py
+6
-4
6 additions, 4 deletions
datasets.py
visualizations.py
+3
-1
3 additions, 1 deletion
visualizations.py
with
9 additions
and
5 deletions
datasets.py
+
6
−
4
View file @
21a8f561
...
...
@@ -80,6 +80,9 @@ class Dataset:
with
open
(
self
.
sel20k
,
"
r
"
)
as
f
:
self
.
sel_20k
=
f
.
readlines
()
self
.
sel_20k
=
[
s
.
replace
(
"
\n
"
,
""
)
for
s
in
self
.
sel_20k
]
# im20k has the ids for each image in an array that matches sel_20k
# sel_20k has an array for images as train2014/COCO_#######
self
.
im20k
=
[
str
(
int
(
s
.
split
(
"
_
"
)[
-
1
].
split
(
"
.
"
)[
0
]))
for
s
in
self
.
sel_20k
]
else
:
raise
ValueError
(
"
Unknown dataset.
"
)
...
...
@@ -120,8 +123,7 @@ class Dataset:
if
"
VOC
"
in
self
.
dataset_name
:
image
=
skimage
.
io
.
imread
(
f
"
datasets/VOC
{
self
.
year
}
/JPEGImages/
{
im_name
}
"
)
elif
"
COCO
"
in
self
.
dataset_name
:
im_path
=
self
.
sel_20k
[
int
(
im_name
)]
image
=
skimage
.
io
.
imread
(
f
"
datasets/COCO/images/
{
im_path
}
"
)
image
=
skimage
.
io
.
imread
(
f
"
datasets/COCO/images/
{
im_name
}
"
)
else
:
raise
ValueError
(
"
Unkown dataset.
"
)
return
image
...
...
@@ -133,8 +135,8 @@ class Dataset:
if
"
VOC
"
in
self
.
dataset_name
:
im_name
=
inp
[
"
annotation
"
][
"
filename
"
]
elif
"
COCO
"
in
self
.
dataset_name
:
im_
name
=
str
(
inp
[
0
][
"
image_id
"
])
im_
id
=
self
.
im20k
.
index
(
str
(
inp
[
0
][
"
image_id
"
])
)
im_name
=
self
.
sel_20k
[
im_id
]
return
im_name
def
extract_gt
(
self
,
targets
,
im_name
):
...
...
This diff is collapsed.
Click to expand it.
visualizations.py
+
3
−
1
View file @
21a8f561
...
...
@@ -19,7 +19,7 @@ import numpy as np
import
torch.nn
as
nn
from
PIL
import
Image
from
random
import
*
import
os
import
matplotlib.pyplot
as
plt
def
visualize_predictions
(
image
,
pred
,
seed
,
scales
,
dims
,
vis_folder
,
im_name
,
plot_seed
=
False
,
is_gt
=
False
):
...
...
@@ -56,6 +56,7 @@ def visualize_predictions(image, pred, seed, scales, dims, vis_folder, im_name,
)
if
im_name
is
not
None
:
pltname
=
f
"
{
vis_folder
}
/LOST_
{
im_name
}
.png
"
os
.
system
(
'
mkdir -p
'
+
os
.
path
.
dirname
(
pltname
))
Image
.
fromarray
(
image
).
save
(
pltname
)
#print(f"Predictions saved at {pltname}.")
...
...
@@ -139,5 +140,6 @@ def visualize_seed_expansion(image, pred, seed, pred_seed, scales, dims, vis_fol
image
[
start_1
:
end_1
,
start_2
:
end_2
,
2
]
=
41
pltname
=
f
"
{
vis_folder
}
/LOST_seed_expansion_
{
im_name
}
.png
"
os
.
system
(
'
mkdir -p
'
+
os
.
path
.
dirname
(
pltname
))
Image
.
fromarray
(
image
).
save
(
pltname
)
print
(
f
"
Image saved at
{
pltname
}
.
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment