Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Basedformer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
novelai-storage
Basedformer
Commits
7e9cc877
Commit
7e9cc877
authored
Jul 06, 2022
by
Eren Doğan
Committed by
GitHub
Jul 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more checks
parent
690dd2cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
basedformer/dataset.py
basedformer/dataset.py
+11
-3
No files found.
basedformer/dataset.py
View file @
7e9cc877
...
...
@@ -10,6 +10,7 @@ import pickle
from
pathlib
import
Path
from
PIL
import
Image
import
requests
import
hashlib
# Does this work with other block_sizes? doesn't seem to.
class
FbDataset
(
data
.
Dataset
):
...
...
@@ -216,10 +217,10 @@ class ImageDatasetBuilder():
else
:
raise
Exception
(
"Metadata file not found at {}"
.
format
(
self
.
metadata_path
))
def
operate
(
self
,
operation
,
batch
,
identities
,
metadata
=
None
,
executor
=
concurrent
.
futures
.
ThreadPoolExecutor
):
def
operate
(
self
,
operation
,
batch
,
identities
,
metadata
=
None
,
executor
=
concurrent
.
futures
.
ThreadPoolExecutor
,
**
kwargs
):
executor
=
executor
(
max_workers
=
self
.
threads
)
futures
=
executor
.
map
(
operation
,
batch
)
futures
=
executor
.
map
(
operation
,
batch
,
**
kwargs
)
futures
=
list
(
futures
)
for
data
,
identity
in
zip
(
futures
,
identities
):
...
...
@@ -237,11 +238,18 @@ class ImageDatasetBuilder():
return
data
def
url_op
(
self
,
url
):
def
url_op
(
self
,
url
,
md5
):
result
=
requests
.
get
(
url
)
for
_
in
range
(
5
):
if
result
.
status_code
==
200
:
break
if
result
.
status_code
!=
200
:
return
None
saved_md5
=
hashlib
.
md5
(
data
)
if
saved_md5
!=
md5
:
return
None
data
=
result
.
content
data
=
self
.
encode_op
(
data
)
...
...
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