Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS626-Project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Meet Narendra
CS626-Project
Commits
6de6f3a4
Commit
6de6f3a4
authored
Nov 08, 2022
by
Meet Narendra
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get annot
parent
76b62e21
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
3 deletions
+50
-3
data_loader.py
data_loader.py
+45
-0
data_utils.py
data_utils.py
+2
-2
download_images.py
download_images.py
+2
-1
model.py
model.py
+1
-0
No files found.
data_loader.py
0 → 100644
View file @
6de6f3a4
from
logger
import
Logger
import
torch
import
torchvision.transforms
as
transforms
from
PIL
import
Image
import
numpy
as
np
LOGGER
=
Logger
()
.
logger
()
#Author: @meetdoshi
from
Utils
import
device
from
data_utils
import
PinDataset
class
DataLoader
():
def
__init__
(
self
):
self
.
pin_dataset
=
PinDataset
(
partitions
=
range
(
1
))
self
.
pin_dataset
.
load_meta_data
()
self
.
pidxs
=
self
.
pin_dataset
.
get_pidxs
()
return
def
get_sample_image
(
self
):
'''
Function to get image,anno
'''
pidx
=
np
.
random
.
choice
(
self
.
pidxs
)
print
(
pidx
,
type
(
pidx
))
image
,
anno
=
self
.
pin_dataset
.
get_annotation
(
pin_id
=
pidx
)
return
image
,
anno
def
get_all_images
(
self
):
'''
Function to get all images
'''
images
=
[]
annotations
=
[]
for
pidx
in
self
.
pidxs
:
print
(
pidx
)
image
,
anno
=
self
.
pin_dataset
.
get_annotation
(
pin_id
=
pidx
)
images
.
append
(
image
)
annotations
.
append
(
anno
)
return
images
,
annotations
'''
if __name__ == "__main__":
data_loader = DataLoader()
image,anno = data_loader.get_sample_image()
print(image,type(image))
print(anno)
'''
data_utils.py
View file @
6de6f3a4
...
...
@@ -148,7 +148,7 @@ class PinDataset(object):
annos
=
[]
pidxs
=
{}
for
meta_path
in
self
.
meta_paths
:
annos
.
extend
(
np
.
load
(
meta_path
)
.
tolist
())
annos
.
extend
(
np
.
load
(
meta_path
,
allow_pickle
=
True
,
encoding
=
'latin1'
)
.
tolist
())
print
(
'Meta data loaded, contains
%
d images.'
%
len
(
annos
))
for
(
ind_a
,
anno
)
in
enumerate
(
annos
):
pidx
=
self
.
_get_pidx_from_image_name
(
anno
[
'image_name'
])
...
...
@@ -161,7 +161,7 @@ class PinDataset(object):
def
get_pidxs
(
self
,
max_return_num
=
None
):
"""Return the list of pinterest image idx in the meta data."""
assert
self
.
annos
is
not
None
,
'Load meta data first, call load_meta_data()'
pidxs_list
=
list
(
self
.
pidxs
.
iterkeys
()
)
pidxs_list
=
list
(
i
for
i
in
self
.
pidxs
)
if
max_return_num
is
not
None
:
num
=
min
(
len
(
pidxs_list
),
max_return_num
)
else
:
...
...
download_images.py
View file @
6de6f3a4
...
...
@@ -11,7 +11,8 @@ from __future__ import division
from
__future__
import
print_function
from
data_utils
import
PinDataset
'''
if __name__ == '__main__':
pin_dataset = PinDataset()
pin_dataset.download_images()
'''
model.py
View file @
6de6f3a4
...
...
@@ -2,6 +2,7 @@ import numpy as np
import
torch
import
torch.nn
as
nn
from
logger
import
Logger
from
data_loader
import
DataLoader
LOGGER
=
Logger
()
.
logger
()
class
Model
():
...
...
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