Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,009 Bytes
1ad0483 8a26694 1ad0483 8a26694 1ad0483 2900131 1c46df5 8a26694 1c46df5 2900131 1c46df5 8a26694 2900131 1c46df5 8a26694 2900131 8a26694 2900131 8a26694 2900131 8a26694 2900131 8a26694 2900131 8a26694 |
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 39 40 |
import gradio as gr
import numpy as np
from chrislib.general import uninvert, invert, view, view_scale
from intrinsic.pipeline import load_models, run_pipeline
intrinsic_models = load_models('v2', device='cpu')
def generate_pipeline(models):
def pipeline_func(image, **kwargs):
return run_pipeline(models, image, **kwargs)
return pipeline_func
pipeline_func = generate_pipeline(intrinsic_models)
def process_image(image):
print(image.shape)
image = image.astype(np.single) / 255.
result = pipeline_func(image, device='cpu')
return [view(result['hr_alb']), 1 - invert(result['dif_shd']), view_scale(result['pos_res'])]
interface = gr.Interface(
fn=process_image,
inputs=gr.components.Image(type="numpy"),
outputs=[
gr.components.Image(type='numpy', label="Albedo"),
gr.components.Image(type='numpy', label="Diffuse Shading"),
gr.components.Image(type='numpy', label="Residual"),
],
live=True
)
interface.launch()
|