Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
69fd990e
Commit
69fd990e
authored
5 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
add a function to load png images
parent
aeaf5733
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/dataset/image.py
+22
-0
22 additions, 0 deletions
bob/learn/tensorflow/dataset/image.py
with
22 additions
and
0 deletions
bob/learn/tensorflow/dataset/image.py
+
22
−
0
View file @
69fd990e
...
...
@@ -197,3 +197,25 @@ def image_augmentation_parser(filename,
features
[
'
key
'
]
=
filename
return
features
,
label
def
load_pngs
(
img_path
,
img_shape
):
"""
Read png files using tensorflow API
You must know the shape of the image beforehand to use this function.
Parameters
----------
img_path : str
Path to the image
img_shape : list
A list or tuple that contains image
'
s shape in channels_last format
Returns
-------
object
The loaded png file
"""
img_raw
=
tf
.
read_file
(
img_path
)
img_tensor
=
tf
.
image
.
decode_png
(
img_raw
,
channels
=
img_shape
[
-
1
])
img_final
=
tf
.
reshape
(
img_tensor
,
img_shape
)
return
img_final
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