Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Segment-Object-Centric
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Alexandre Chapin
Segment-Object-Centric
Commits
5a01f6ca
Commit
5a01f6ca
authored
2 years ago
by
Alexandre Chapin
Browse files
Options
Downloads
Patches
Plain Diff
Change device slots
parent
8d45a44b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
osrt/encoder.py
+3
-4
3 additions, 4 deletions
osrt/encoder.py
osrt/layers.py
+2
-2
2 additions, 2 deletions
osrt/layers.py
osrt/model.py
+3
-1
3 additions, 1 deletion
osrt/model.py
with
8 additions
and
7 deletions
osrt/encoder.py
+
3
−
4
View file @
5a01f6ca
...
...
@@ -174,7 +174,6 @@ class FeatureMasking(nn.Module):
num_slots
=
100000
for
b
in
range
(
B
):
latents_batch
=
torch
.
empty
((
1
,
dim
),
device
=
self
.
mask_generator
.
device
)
# TODO : set a new number of slots
for
n
in
range
(
N
):
embeds
=
masks
[
b
][
n
][
"
embeddings
"
]
num_slots
=
min
(
len
(
embeds
),
num_slots
)
...
...
@@ -270,11 +269,11 @@ class SamAutomaticMask(nn.Module):
input_size
=
0
# depends on the image size
self
.
token_dim
=
(
self
.
image_encoder
.
img_size
//
patch_size
)
**
2
self
.
tokenizer
=
nn
.
Sequential
(
nn
.
Linear
(
input_size
,
1
00
),
nn
.
Linear
(
self
.
token_dim
,
35
00
),
nn
.
ReLU
(),
nn
.
Linear
(
1
00
,
5
0
),
nn
.
Linear
(
35
00
,
250
0
),
nn
.
ReLU
(),
nn
.
Linear
(
50
,
self
.
token_dim
),
nn
.
Linear
(
2500
,
2048
),
)
# Space positional embedding
...
...
This diff is collapsed.
Click to expand it.
osrt/layers.py
+
2
−
2
View file @
5a01f6ca
...
...
@@ -229,10 +229,10 @@ class SlotAttention(nn.Module):
inputs
=
self
.
norm_input
(
inputs
)
if
self
.
randomize_initial_slots
:
slot_means
=
self
.
initial_slots
.
unsqueeze
(
0
).
expand
(
batch_size
,
-
1
,
-
1
)
# from [num_slots, slot_dim] to [batch_size, num_slots, slot_dim]
slot_means
=
self
.
initial_slots
.
unsqueeze
(
0
).
expand
(
batch_size
,
-
1
,
-
1
)
.
to
(
inputs
.
device
)
# from [num_slots, slot_dim] to [batch_size, num_slots, slot_dim]
slots
=
torch
.
distributions
.
Normal
(
slot_means
,
self
.
embedding_stdev
).
rsample
()
else
:
slots
=
self
.
initial_slots
.
unsqueeze
(
0
).
expand
(
batch_size
,
-
1
,
-
1
)
slots
=
self
.
initial_slots
.
unsqueeze
(
0
).
expand
(
batch_size
,
-
1
,
-
1
)
.
to
(
inputs
.
device
)
k
,
v
=
self
.
to_k
(
inputs
),
self
.
to_v
(
inputs
)
...
...
This diff is collapsed.
Click to expand it.
osrt/model.py
+
3
−
1
View file @
5a01f6ca
from
torch
import
nn
from
osrt.encoder
import
OSRTEncoder
,
ImprovedSRTEncoder
from
osrt.encoder
import
OSRTEncoder
,
ImprovedSRTEncoder
,
FeatureMasking
from
osrt.decoder
import
SlotMixerDecoder
,
SpatialBroadcastDecoder
,
ImprovedSRTDecoder
import
osrt.layers
as
layers
...
...
@@ -17,6 +17,8 @@ class OSRT(nn.Module):
self
.
encoder
=
ImprovedSRTEncoder
(
**
cfg
[
'
encoder_kwargs
'
])
elif
encoder_type
==
'
osrt
'
:
self
.
encoder
=
OSRTEncoder
(
**
cfg
[
'
encoder_kwargs
'
])
elif
encoder_type
==
'
sam
'
:
self
.
encoder
=
FeatureMasking
(
**
cfg
[
'
encoder_kwargs
'
])
else
:
raise
ValueError
(
f
'
Unknown encoder type:
{
encoder_type
}
'
)
...
...
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