FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ControlNet/tutorial_dataset.py at main · chokami/ControlNet · GitHub
chokami
/
ControlNet
Public
forked from
lllyasviel/ControlNet
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ControlNet
/
tutorial_dataset.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (27 loc) · 1.08 KB
Breadcrumbs
ControlNet
/
tutorial_dataset.py
Copy path
File metadata and controls
39 lines (27 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import
json
import
cv2
import
numpy
as
np
from
torch
.
utils
.
data
import
Dataset
class
MyDataset
(
Dataset
):
def
__init__
(
self
):
self
.
data
=
[]
with
open
(
'./training/fill50k/prompt.json'
,
'rt'
)
as
f
:
for
line
in
f
:
self
.
data
.
append
(
json
.
loads
(
line
))
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
idx
):
item
=
self
.
data
[
idx
]
source_filename
=
item
[
'source'
]
target_filename
=
item
[
'target'
]
prompt
=
item
[
'prompt'
]
source
=
cv2
.
imread
(
'./training/fill50k/'
+
source_filename
)
target
=
cv2
.
imread
(
'./training/fill50k/'
+
target_filename
)
# Do not forget that OpenCV read images in BGR order.
source
=
cv2
.
cvtColor
(
source
,
cv2
.
COLOR_BGR2RGB
)
target
=
cv2
.
cvtColor
(
target
,
cv2
.
COLOR_BGR2RGB
)
# Normalize source images to [0, 1].
source
=
source
.
astype
(
np
.
float32
)
/
255.0
# Normalize target images to [-1, 1].
target
=
(
target
.
astype
(
np
.
float32
)
/
127.5
)
-
1.0
return
dict
(
jpg
=
target
,
txt
=
prompt
,
hint
=
source
)
Back
|
FazBrowse Home
|
New Git URL