Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
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
Stable Diffusion Webui
Commits
c7561335
Commit
c7561335
authored
Dec 27, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add experimental HAT model
parent
b621a63c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
modules/hat_model.py
modules/hat_model.py
+42
-0
No files found.
modules/hat_model.py
0 → 100644
View file @
c7561335
import
os
import
sys
from
modules
import
modelloader
,
devices
from
modules.shared
import
opts
from
modules.upscaler
import
Upscaler
,
UpscalerData
from
modules.upscaler_utils
import
upscale_with_model
class
UpscalerHAT
(
Upscaler
):
def
__init__
(
self
,
dirname
):
self
.
name
=
"HAT"
self
.
scalers
=
[]
self
.
user_path
=
dirname
super
()
.
__init__
()
for
file
in
self
.
find_models
(
ext_filter
=
[
".pt"
,
".pth"
]):
name
=
modelloader
.
friendly_name
(
file
)
scale
=
4
# TODO: scale might not be 4, but we can't know without loading the model
scaler_data
=
UpscalerData
(
name
,
file
,
upscaler
=
self
,
scale
=
scale
)
self
.
scalers
.
append
(
scaler_data
)
def
do_upscale
(
self
,
img
,
selected_model
):
try
:
model
=
self
.
load_model
(
selected_model
)
except
Exception
as
e
:
print
(
f
"Unable to load HAT model {selected_model}: {e}"
,
file
=
sys
.
stderr
)
return
img
model
.
to
(
devices
.
device_esrgan
)
# TODO: should probably be device_hat
return
upscale_with_model
(
model
,
img
,
tile_size
=
opts
.
ESRGAN_tile
,
# TODO: should probably be HAT_tile
tile_overlap
=
opts
.
ESRGAN_tile_overlap
,
# TODO: should probably be HAT_tile_overlap
)
def
load_model
(
self
,
path
:
str
):
if
not
os
.
path
.
isfile
(
path
):
raise
FileNotFoundError
(
f
"Model file {path} not found"
)
return
modelloader
.
load_spandrel_model
(
path
,
device
=
devices
.
device_esrgan
,
# TODO: should probably be device_hat
)
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