Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
AuraSR-v2
Commits
83222671
"examples/vscode:/vscode.git/clone" did not exist on "9e7aeea1b5e9d02019f0596f9639905c968f7013"
Commit
83222671
authored
Aug 05, 2024
by
chenpangpang
Browse files
feat: zancun
parent
43f12e23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
24 deletions
+18
-24
AuraSR-v2/app.py
AuraSR-v2/app.py
+14
-21
AuraSR-v2/requirements.txt
AuraSR-v2/requirements.txt
+3
-2
启动器.ipynb
启动器.ipynb
+1
-1
No files found.
AuraSR-v2/app.py
View file @
83222671
import
gradio
as
gr
from
PIL
import
Image
import
numpy
as
np
from
aura_sr
import
AuraSR
import
torch
import
os
# # Force CPU usage
# torch.set_default_type(torch.FloatTensor)
# torch.set_default_device('cpu')
#
# # Override torch.load to always use CPU
# original_load = torch.load
# torch.load = lambda *args, **kwargs: original_load(*args, **kwargs, map_location=torch.device('cpu'))
# Initialize the AuraSR model
aura_sr
=
AuraSR
.
from_pretrained
(
"fal/AuraSR-v2/model.safetensors"
)
USE_TORCH_COMPILE
=
False
ENABLE_CPU_OFFLOAD
=
os
.
getenv
(
"ENABLE_CPU_OFFLOAD"
,
"0"
)
==
"1"
device
=
torch
.
device
(
"cuda"
if
torch
.
cuda
.
is_available
()
else
"cpu"
)
#
# Restore original torch.load
# torch.load = original_load
#
Initialize the AuraSR model
aura_sr
=
AuraSR
.
from_pretrained
(
"fal/AuraSR-v2/model.safetensors"
)
def
process_image
(
input_image
):
if
input_image
is
None
:
raise
gr
.
Error
(
"Please provide an image to upscale."
)
# Convert to PIL Image for resizing
pil_image
=
Image
.
fromarray
(
input_image
)
print
(
"get input image: "
,
input_image
)
# Upscale the image using AuraSR
upscaled_image
=
process_image_on_gpu
(
pil
_image
)
upscaled_image
=
process_image_on_gpu
(
input
_image
)
print
(
"upscaled_image: "
,
upscaled_image
)
return
upscaled_image
def
process_image_on_gpu
(
pil_image
):
return
aura_sr
.
upscale_4x
(
pil_image
)
title
=
"""<h1 align="center">AuraSR-v2:一款基于GAN图像修复工具,可从低分辨率图片生成高分辨率图片</h1>"""
title
=
"""<h1 align="center">AuraSR-v2:一款基于GAN
的
图像修复工具,可从低分辨率图片生成高分辨率图片</h1>"""
with
gr
.
Blocks
()
as
demo
:
gr
.
HTML
(
title
)
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
1
):
input_image
=
gr
.
Image
(
label
=
"输入图片"
,
type
=
"numpy
"
)
input_image
=
gr
.
Image
(
type
=
"pil"
,
label
=
"输入图片
"
)
process_btn
=
gr
.
Button
(
"生成"
)
with
gr
.
Column
(
scale
=
1
):
gallery
=
gr
.
Image
(
label
=
"生成图片"
)
...
...
@@ -61,7 +54,7 @@ with gr.Blocks() as demo:
inputs
=
input_image
,
outputs
=
gallery
,
fn
=
process_image
,
cache_examples
=
True
cache_examples
=
True
,
)
demo
.
launch
(
server_name
=
'0.0.0.0'
,
share
=
True
)
AuraSR-v2/requirements.txt
View file @
83222671
spaces
aura-sr
\ No newline at end of file
aura-sr
diffusers
gradio==3.40.0
\ No newline at end of file
启动器.ipynb
View file @
83222671
...
...
@@ -18,7 +18,7 @@
"\n",
"## 功能介绍\n",
"- 原项目地址:https://huggingface.co/spaces/gokaygokay/AuraSR-v2\n",
"- AuraSR-v2:一款基于GAN图像修复工具,可从低分辨率图片生成高分辨率图片"
"- AuraSR-v2:一款基于GAN
的
图像修复工具,可从低分辨率图片生成高分辨率图片"
]
},
{
...
...
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