Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_embedding
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
strategy_embedding
Commits
390e41e0
Commit
390e41e0
authored
Sep 11, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update request f
parent
b773aebf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
images.py
src/utils/images.py
+12
-9
No files found.
src/utils/images.py
View file @
390e41e0
...
...
@@ -10,17 +10,20 @@ from PIL import Image
def
url_to_ndarray
(
url
):
result
=
requests
.
get
(
url
,
timeout
=
30
)
if
result
.
ok
:
img
=
Image
.
open
(
io
.
BytesIO
(
result
.
content
))
img
=
img
.
convert
(
"RGB"
)
data
=
np
.
array
(
img
)
return
data
else
:
print
(
"http get: {}"
.
format
(
result
.
status_code
))
try
:
result
=
requests
.
get
(
url
,
timeout
=
30
)
if
result
.
ok
:
img
=
Image
.
open
(
io
.
BytesIO
(
result
.
content
))
img
=
img
.
convert
(
"RGB"
)
data
=
np
.
array
(
img
)
return
data
else
:
print
(
"http get: {}"
.
format
(
result
.
status_code
))
return
np
.
array
([])
except
Exception
as
e
:
print
(
e
)
return
np
.
array
([])
def
file_to_ndarray
(
path
):
result
=
cv2
.
imread
(
path
)
img
=
Image
.
fromarray
(
result
)
.
convert
(
"RGB"
)
...
...
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