LN1996 commited on
Commit
4fb9833
1 Parent(s): b110321

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -4,19 +4,38 @@ import gradio as gr
4
 
5
  f = modal.Cls.lookup("casa-interior-hf-v2", "DesignModel")
6
 
 
 
 
 
 
7
 
8
- def casa_ai_run(dict=None, text=None):
 
9
 
 
 
10
  image = dict["background"].convert("RGB")
11
  mask = dict["layers"][0].convert('L')
12
 
13
  if image is None and text is None:
14
- print('Please provide context in form of image, audio, text')
15
  return None
16
 
17
- result_image = f.inference.remote(image, text, mask)
18
  return result_image
19
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  with gr.Blocks() as casa:
22
  title = "Casa-AI Demo"
@@ -26,13 +45,13 @@ with gr.Blocks() as casa:
26
  with gr.Row():
27
  with gr.Column():
28
  inputs = [
29
- gr.ImageEditor(sources='upload', brush=gr.Brush(colors=["#FFFFFF"]), elem_id="image_upload", type="pil", label="Upload", layers=False, eraser=True, transforms=[]),
30
  gr.Textbox(label="Prompt to design room")]
31
  with gr.Column():
32
  outputs = [gr.Image(label="Generated room image")]
33
 
34
  submit_btn = gr.Button("Submit")
35
- submit_btn.click(casa_ai_run, inputs=inputs, outputs=outputs)
36
 
37
 
38
  with gr.Tab("ReDesign"):
 
4
 
5
  f = modal.Cls.lookup("casa-interior-hf-v2", "DesignModel")
6
 
7
+ def casa_ai_run_tab1(image=None, prompt=None):
8
+
9
+ if image is None and text is None:
10
+ print('Please provide context in form of image, text')
11
+ return None
12
 
13
+ result_image = f.inference.remote("tab1", image, text)
14
+ return result_image
15
 
16
+ def casa_ai_run_tab2(dict=None, text=None):
17
+
18
  image = dict["background"].convert("RGB")
19
  mask = dict["layers"][0].convert('L')
20
 
21
  if image is None and text is None:
22
+ print('Please provide context in form of image, text')
23
  return None
24
 
25
+ result_image = f.inference.remote("tab2", image, text, mask)
26
  return result_image
27
 
28
+ def casa_ai_run_tab3(dict=None, text=None):
29
+
30
+ image = dict["background"].convert("RGB")
31
+ mask = dict["layers"][0].convert('L')
32
+
33
+ if image is None and text is None:
34
+ print('Please provide context in form of image, text')
35
+ return None
36
+
37
+ result_image = f.inference.remote("tab3", image, text, mask)
38
+ return result_image
39
 
40
  with gr.Blocks() as casa:
41
  title = "Casa-AI Demo"
 
45
  with gr.Row():
46
  with gr.Column():
47
  inputs = [
48
+ gr.Image(sources='upload', type="pil", label="Upload"),
49
  gr.Textbox(label="Prompt to design room")]
50
  with gr.Column():
51
  outputs = [gr.Image(label="Generated room image")]
52
 
53
  submit_btn = gr.Button("Submit")
54
+ submit_btn.click(casa_ai_run_tab1, inputs=inputs, outputs=outputs)
55
 
56
 
57
  with gr.Tab("ReDesign"):