Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
40a0ab79
Unverified
Commit
40a0ab79
authored
May 11, 2022
by
Philip Meier
Committed by
GitHub
May 11, 2022
Browse files
remove SampleQuery from prototype datasets (#5991)
parent
e6edcef4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
42 deletions
+0
-42
torchvision/prototype/datasets/utils/__init__.py
torchvision/prototype/datasets/utils/__init__.py
+0
-1
torchvision/prototype/datasets/utils/_query.py
torchvision/prototype/datasets/utils/_query.py
+0
-41
No files found.
torchvision/prototype/datasets/utils/__init__.py
View file @
40a0ab79
from
.
import
_internal
# usort: skip
from
.
import
_internal
# usort: skip
from
._dataset
import
Dataset
from
._dataset
import
Dataset
from
._query
import
SampleQuery
from
._resource
import
OnlineResource
,
HttpResource
,
GDriveResource
,
ManualDownloadResource
,
KaggleDownloadResource
from
._resource
import
OnlineResource
,
HttpResource
,
GDriveResource
,
ManualDownloadResource
,
KaggleDownloadResource
torchvision/prototype/datasets/utils/_query.py
deleted
100644 → 0
View file @
e6edcef4
import
collections.abc
from
typing
import
Any
,
Callable
,
Iterator
,
Optional
,
Tuple
,
TypeVar
,
cast
from
torchvision.prototype.features
import
BoundingBox
,
Image
T
=
TypeVar
(
"T"
)
class
SampleQuery
:
def
__init__
(
self
,
sample
:
Any
)
->
None
:
self
.
sample
=
sample
@
staticmethod
def
_query_recursively
(
sample
:
Any
,
fn
:
Callable
[[
Any
],
Optional
[
T
]])
->
Iterator
[
T
]:
if
isinstance
(
sample
,
(
collections
.
abc
.
Sequence
,
collections
.
abc
.
Mapping
)):
for
item
in
sample
.
values
()
if
isinstance
(
sample
,
collections
.
abc
.
Mapping
)
else
sample
:
yield
from
SampleQuery
.
_query_recursively
(
item
,
fn
)
else
:
result
=
fn
(
sample
)
if
result
is
not
None
:
yield
result
def
query
(
self
,
fn
:
Callable
[[
Any
],
Optional
[
T
]])
->
T
:
results
=
set
(
self
.
_query_recursively
(
self
.
sample
,
fn
))
if
not
results
:
raise
RuntimeError
(
"Query turned up empty."
)
elif
len
(
results
)
>
1
:
raise
RuntimeError
(
f
"Found more than one result:
{
results
}
"
)
return
results
.
pop
()
def
image_size
(
self
)
->
Tuple
[
int
,
int
]:
def
fn
(
sample
:
Any
)
->
Optional
[
Tuple
[
int
,
int
]]:
if
isinstance
(
sample
,
Image
):
return
cast
(
Tuple
[
int
,
int
],
sample
.
shape
[
-
2
:])
elif
isinstance
(
sample
,
BoundingBox
):
return
sample
.
image_size
else
:
return
None
return
self
.
query
(
fn
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment