Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85877939
Augmentations.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Oct 2, 17:34
Size
1018 B
Mime Type
text/x-c++
Expires
Fri, Oct 4, 17:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21288854
Attached To
R12521 Laser-DED Self supervised learning-Coaxial Imaging
Augmentations.py
View Options
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 19 15:24:26 2022
@author: srpv
"""
import
torch
import
torch.nn
as
nn
import
torchvision.transforms
as
torch_tf
import
torchvision
class
Solarization
(
nn
.
Module
):
def
__call__
(
self
,
x
):
return
torch_tf
.
functional
.
solarize
(
x
,
threshold
=
0.5
)
def
augmentation_tau_prime
(
p_blur
=
0.1
,
p_solarize
=
0.2
):
return
nn
.
Sequential
(
torch_tf
.
RandomApply
(
torch
.
nn
.
ModuleList
([
torch_tf
.
RandomRotation
(
degrees
=
(
0
,
180
),
interpolation
=
torchvision
.
transforms
.
InterpolationMode
.
NEAREST
,
fill
=
0.065
)]),
p
=
0.75
),
torch_tf
.
RandomHorizontalFlip
(
p
=
0.75
),
torch_tf
.
RandomVerticalFlip
(
p
=
0.75
),
)
def
augmentation_tau
():
return
nn
.
Sequential
(
torch_tf
.
RandomApply
(
torch
.
nn
.
ModuleList
([
torch_tf
.
RandomRotation
(
degrees
=
(
0
,
90
),
interpolation
=
torchvision
.
transforms
.
InterpolationMode
.
NEAREST
,
fill
=
0.065
)]),
p
=
0.25
),
torch_tf
.
RandomHorizontalFlip
(
p
=
0.25
),
torch_tf
.
RandomVerticalFlip
(
p
=
0.25
),
)
Event Timeline
Log In to Comment