Spaces:
Running
Running
File size: 3,002 Bytes
2e40cec 68e098f 2e40cec cb7c43d 2e40cec 68e098f c01661b aeb7cb4 7815fb5 937ea93 c01661b a65d535 cb7c43d a65d535 2069ee0 68e098f 18a36b2 fa2fb4a 68e098f b110321 68e098f b110321 f8ac765 b110321 68e098f b110321 |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
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"):
with gr.Row():
with gr.Column():
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")]
with gr.Column():
outputs = [gr.Image(label="Generated room image")]
submit_btn = gr.Button("Submit")
submit_btn.click(casa_ai_run, inputs=inputs, outputs=outputs)
with gr.Tab("ReDesign"):
with gr.Row():
with gr.Column():
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 for redesigning masked object")]
with gr.Column():
outputs = [gr.Image(label="Image with new designed object")]
submit_btn = gr.Button("Submit")
submit_btn.click(casa_ai_run, inputs=inputs, outputs=outputs)
with gr.Tab("Recommendation"):
with gr.Row():
with gr.Column():
inputs = [
gr.ImageEditor(sources='upload', brush=gr.Brush(colors=["#FFFFFF"]), elem_id="image_upload", type="pil", label="Upload", layers=False, eraser=True, transforms=[]),
]
with gr.Column():
outputs = [gr.Image(label="Image with new designed object")]
submit_btn = gr.Button("Submit")
submit_btn.click(casa_ai_run, inputs=inputs, outputs=outputs)
casa.launch()
# 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,
# )
# demo.launch() |