Sijuade commited on
Commit
176a9a1
1 Parent(s): b551853

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
app.py CHANGED
@@ -56,6 +56,18 @@ def casa_ai_run_tab3(dict=None):
56
 
57
  def casa_ai_run_tab_sketch(image=None, room_type=None, room_style=None):
58
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  text = f"{room_type}, {room_style}"
60
  f = modal.Cls.lookup("casa-interior-hf-v6-sketch", "DesignModel")
61
  result_image = f.inference.remote(image, text)
@@ -85,6 +97,26 @@ with gr.Blocks() as casa:
85
  ['example_images/image_2.jpg', 'Modern bedroom art deco style']],
86
  inputs=inputs, outputs=outputs, fn=casa_ai_run_tab1, cache_examples=True)
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  with gr.Tab("Redesign"):
90
  with gr.Row():
@@ -111,19 +143,4 @@ with gr.Blocks() as casa:
111
  submit_btn.click(casa_ai_run_tab3, inputs=inputs, outputs=outputs)
112
 
113
 
114
- with gr.Tab("Re"):
115
- with gr.Row():
116
- with gr.Column():
117
- inputs = [
118
- gr.Image(sources='upload', type="numpy", label="Upload"),
119
- gr.Dropdown(["Living Room", "Bedroom", "Kitchen"], label="Room Type", info="Select Room Type"),
120
- gr.Dropdown(["Modern", "Minimalist", "Scandinavian"], label="Style", info="Interior Style!"),
121
- ]
122
-
123
- with gr.Column():
124
- outputs = [gr.Image(label="Image with new designed object")]
125
-
126
- submit_btn = gr.Button("Redesign!")
127
- submit_btn.click(casa_ai_run_tab_sketch, inputs=inputs, outputs=outputs)
128
-
129
  casa.launch()
 
56
 
57
  def casa_ai_run_tab_sketch(image=None, room_type=None, room_style=None):
58
 
59
+ if image is None:
60
+ print('Please provide a sketch or ketchup image')
61
+ return None
62
+
63
+ if room_type is None:
64
+ print('Please select a room type')
65
+ return None
66
+
67
+ if room_style is None:
68
+ print('Please select a room style')
69
+ return None
70
+
71
  text = f"{room_type}, {room_style}"
72
  f = modal.Cls.lookup("casa-interior-hf-v6-sketch", "DesignModel")
73
  result_image = f.inference.remote(image, text)
 
97
  ['example_images/image_2.jpg', 'Modern bedroom art deco style']],
98
  inputs=inputs, outputs=outputs, fn=casa_ai_run_tab1, cache_examples=True)
99
 
100
+
101
+ with gr.Tab("Sketch Transform"):
102
+ with gr.Row():
103
+ with gr.Column():
104
+ inputs = [
105
+ gr.Image(sources='upload', type="numpy", label="Upload"),
106
+ gr.Dropdown(["Living Room", "Bedroom", "Kitchen"], label="Room Type", info="Select Room Type"),
107
+ gr.Dropdown(["Modern", "Minimalist", "Scandinavian"], label="Style", info="Interior Style!"),
108
+ ]
109
+
110
+ with gr.Column():
111
+ outputs = [gr.Image(label="Image of sketch transformed")]
112
+
113
+ submit_btn = gr.Button("Transform!")
114
+ submit_btn.click(casa_ai_run_tab_sketch, inputs=inputs, outputs=outputs)
115
+ gr.Examples(examples=[['example_images/sketch01.jpeg 'Living Room', 'Modern'],
116
+ ['example_images/sketch02.jpeg', 'Bedroom', 'Minimalist'],
117
+ ['example_images/sketchup.jpeg', 'Kitchen', 'Modern']],
118
+ inputs=inputs, outputs=outputs, fn=casa_ai_run_tab_sketch, cache_examples=True)
119
+
120
 
121
  with gr.Tab("Redesign"):
122
  with gr.Row():
 
143
  submit_btn.click(casa_ai_run_tab3, inputs=inputs, outputs=outputs)
144
 
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  casa.launch()