设置deloldify模型位置
parent
ce975e9f4e
commit
a365308d3e
|
|
@ -3,7 +3,7 @@ Author: SpenserCai
|
|||
Date: 2023-07-28 14:37:09
|
||||
version:
|
||||
LastEditors: SpenserCai
|
||||
LastEditTime: 2023-08-01 10:39:29
|
||||
LastEditTime: 2023-08-03 14:31:04
|
||||
Description: file content
|
||||
'''
|
||||
import os
|
||||
|
|
@ -12,7 +12,7 @@ import urllib.request
|
|||
from tqdm import tqdm
|
||||
# 从huggingface下载权重
|
||||
|
||||
models_dir = os.path.abspath("models")
|
||||
models_dir = os.path.abspath("models/deoldify")
|
||||
stable_model_url = "https://huggingface.co/spensercai/DeOldify/resolve/main/ColorizeStable_gen.pth"
|
||||
artistic_model_url = "https://huggingface.co/spensercai/DeOldify/resolve/main/ColorizeArtistic_gen.pth"
|
||||
video_model_url = "https://huggingface.co/spensercai/DeOldify/resolve/main/ColorizeVideo_gen.pth"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Author: SpenserCai
|
|||
Date: 2023-07-28 14:37:40
|
||||
version:
|
||||
LastEditors: SpenserCai
|
||||
LastEditTime: 2023-08-03 13:54:15
|
||||
LastEditTime: 2023-08-03 14:41:58
|
||||
Description: file content
|
||||
'''
|
||||
# DeOldify API
|
||||
|
|
@ -30,7 +30,7 @@ def deoldify_api(_: gr.Blocks, app: FastAPI):
|
|||
render_factor: int = Body(35,title="render factor"),
|
||||
artistic: bool = Body(False,title="artistic")
|
||||
):
|
||||
vis = get_image_colorizer(render_factor=render_factor, artistic=artistic)
|
||||
vis = get_image_colorizer(root_folder=Path("models/deoldify"),render_factor=render_factor, artistic=artistic)
|
||||
# 把base64转换成图片 PIL.Image
|
||||
img = Image.open(BytesIO(base64.b64decode(input_image)))
|
||||
outImg = vis.get_transformed_image_from_image(img, render_factor=render_factor)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Author: SpenserCai
|
|||
Date: 2023-07-28 14:41:28
|
||||
version:
|
||||
LastEditors: SpenserCai
|
||||
LastEditTime: 2023-08-03 14:02:30
|
||||
LastEditTime: 2023-08-03 14:40:50
|
||||
Description: file content
|
||||
'''
|
||||
# DeOldify UI & Processing
|
||||
|
|
@ -24,7 +24,7 @@ warnings.filterwarnings("ignore", category=FutureWarning, message="Arguments oth
|
|||
|
||||
class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
|
||||
name = "Deoldify"
|
||||
order = 20000
|
||||
order = 20999
|
||||
model = None
|
||||
|
||||
def ui(self):
|
||||
|
|
@ -44,7 +44,7 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
|
|||
}
|
||||
|
||||
def process_image(self, image, render_factor, artistic):
|
||||
vis = get_image_colorizer(render_factor=render_factor, artistic=artistic)
|
||||
vis = get_image_colorizer(root_folder=Path("models/deoldify"),render_factor=render_factor, artistic=artistic)
|
||||
outImg = vis.get_transformed_image_from_image(image, render_factor=render_factor)
|
||||
return outImg
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue