Casa-AI / app.py
Sijuade's picture
Update app.py
f8ac765 verified
raw
history blame
1.77 kB
import modal
import gradio as gr
f = modal.Cls.lookup("casa-interior-hf-v2", "DesignModel")
def casa_ai_run(dict=None, text=None):
image = dict["background"].convert("RGB")
mask = dict["layers"][0].convert('L')
if image is None and text is None:
print('Please provide context in form of image, audio, text')
return None
result_image = f.inference.remote(image, text, mask)
return result_image
with gr.Blocks() as casa:
title = "Casa-AI Demo"
description = "A Gradio interface to use CasaAI for virtual staging"
with gr.Tab("ReImagine"):
inputs = [
gr.ImageEditor(sources='upload', brush=gr.Brush(colors=["#FFFFFF"]), elem_id="image_upload", type="pil", label="Upload", layers=False, eraser=True, transforms=[]),
gr.Textbox(label="Prompt to design room")]
outputs = [gr.Image(label="Generated room image")]
submit_btn = gr.Button("Submit")
with gr.Tab("ReDesign"):
pass
with gr.Tab("Recommendation"):
pass
submit_btn.click(casa_ai_run, inputs=inputs, outputs=outputs)
# demo = gr.Interface(casa_ai_run,
# inputs = [gr.ImageEditor(sources='upload', brush=gr.Brush(colors=["#FFFFFF"]), elem_id="image_upload", type="pil", label="Upload", layers=False, eraser=True, transforms=[]),
# gr.Textbox(label="Prompt to design room"),
# ],
# outputs = [
# gr.Image(label="Generated room image"),
# ],
# title = title,
# description = description,
# )
casa.launch()