ccareaga commited on
Commit
2900131
·
verified ·
1 Parent(s): 8c055ae

trying to update with the new pipeline

Browse files
Files changed (1) hide show
  1. app.py +32 -17
app.py CHANGED
@@ -2,25 +2,40 @@ import gradio as gr
2
 
3
  from chrislib.general import uninvert, view
4
 
5
- from intrinsic.pipeline import run_pipeline
6
- from intrinsic.model_util import load_models
7
 
8
- global intrinsic_model
9
- intrinsic_model = load_models('paper_weights', device='cpu')
10
 
11
- def decompose(img):
12
- result = run_pipeline(
13
- img,
14
- intrinsic_model,
15
- device='cpu'
16
- )
17
 
18
- return view(uninvert(result['inv_shd'])), "Completed"
 
 
 
19
 
20
 
21
- gr.Interface(
22
- decompose,
23
- [gr.inputs.Image(type="numpy", label="Input")],
24
- [gr.outputs.Image(type="numpy", label="Output"), gr.outputs.Textbox(label=":")],
25
- examples=[["avocado.jpg"]]
26
- ).launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  from chrislib.general import uninvert, view
4
 
5
+ from intrinsic.pipeline import load_models, run_pipeline
 
6
 
7
+ # load the intrinsic models
8
+ intrinsic_models = load_models('v2')
9
 
10
+ def generate_pipeline(models):
 
 
 
 
 
11
 
12
+ def pipeline_func(image):
13
+ return run_pipeline(models, image, device='cuda')
14
+
15
+ return pipeline_func
16
 
17
 
18
+ run_pipeline = generate_pipeline(intrinsic_models)
19
+
20
+ def process_image(image):
21
+ print(image.shape)
22
+
23
+ # Process the image with your model pipeline
24
+ result = run_pipeline(image)
25
+
26
+ out_keys = ['hr_alb', 'dif_shd', 'pos_res']
27
+ # Create a list to store output images
28
+ output_images = []
29
+ for k in out_keys:
30
+ output_images.append(result[k])
31
+
32
+ return output_images
33
+
34
+ interface = gr.Interface(
35
+ fn=process_image,
36
+ inputs=gr.inputs.Image(type="numpy"),
37
+ outputs=gr.outputs.Image(type="numpy", label="Output Images", tool="editor"),
38
+ live=True
39
+ )
40
+
41
+ interface.launch()