Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,91 +1,4 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
-
import numpy as np
|
4 |
-
from io import BytesIO
|
5 |
-
import requests
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
import requests
|
10 |
-
from io import BytesIO
|
11 |
-
from google.cloud import vision
|
12 |
-
from google.oauth2 import service_account
|
13 |
-
import PIL
|
14 |
-
|
15 |
-
|
16 |
-
def casa_ai_run_tab1(image=None, text=None):
|
17 |
-
|
18 |
-
if image is None:
|
19 |
-
print('Please provide image of empty room to design')
|
20 |
-
return None
|
21 |
-
|
22 |
-
if text is None:
|
23 |
-
print('Please provide a text prompt')
|
24 |
-
return None
|
25 |
-
|
26 |
-
result_image = f.inference.remote("tab1", image, text)
|
27 |
-
return result_image
|
28 |
-
|
29 |
-
def casa_ai_run_tab2(dict=None, text=None):
|
30 |
-
|
31 |
-
image = dict["background"].convert("RGB")
|
32 |
-
mask = dict["layers"][0].convert('L')
|
33 |
-
|
34 |
-
if np.sum(np.array(mask)) == 0:
|
35 |
-
mask = None
|
36 |
-
|
37 |
-
if mask is None:
|
38 |
-
print('Please provide a mask over the object you want to generate again.')
|
39 |
-
|
40 |
-
if image is None and text is None:
|
41 |
-
print('Please provide context in form of image, text')
|
42 |
-
return None
|
43 |
-
|
44 |
-
result_image = f.inference.remote("tab2", image, text, mask)
|
45 |
-
return result_image
|
46 |
-
|
47 |
-
|
48 |
-
with gr.Blocks() as casa:
|
49 |
-
title = "Casa-AI Demo"
|
50 |
-
description = "A Gradio interface to use CasaAI for virtual staging"
|
51 |
-
|
52 |
-
with gr.Tab("Reimagine"):
|
53 |
-
with gr.Row():
|
54 |
-
with gr.Column():
|
55 |
-
inputs = [
|
56 |
-
gr.Image(sources='upload', type="pil", label="Upload"),
|
57 |
-
gr.Textbox(label="Room description.")
|
58 |
-
]
|
59 |
-
with gr.Column():
|
60 |
-
outputs = [gr.Image(label="Generated room image")]
|
61 |
-
|
62 |
-
|
63 |
-
submit_btn = gr.Button("Generate!")
|
64 |
-
submit_btn.click(casa_ai_run_tab1, inputs=inputs, outputs=outputs)
|
65 |
-
|
66 |
-
|
67 |
-
with gr.Tab("Redesign"):
|
68 |
-
with gr.Row():
|
69 |
-
with gr.Column():
|
70 |
-
inputs = [
|
71 |
-
gr.ImageEditor(sources='upload', brush=gr.Brush(colors=["#FFFFFF"]), elem_id="image_upload", type="pil", label="Upload", layers=False, eraser=True, transforms=[]),
|
72 |
-
gr.Textbox(label="Description for redesigning masked object")]
|
73 |
-
with gr.Column():
|
74 |
-
outputs = [gr.Image(label="Image with new designed object")]
|
75 |
-
|
76 |
-
submit_btn = gr.Button("Redesign!")
|
77 |
-
submit_btn.click(casa_ai_run_tab2, inputs=inputs, outputs=outputs)
|
78 |
-
|
79 |
-
with gr.Tab("Recommendation"):
|
80 |
-
with gr.Row():
|
81 |
-
with gr.Column():
|
82 |
-
inputs = [
|
83 |
-
gr.ImageEditor(sources='upload', elem_id="image_upload", type="numpy", label="Upload", layers=False, eraser=False, brush=False, transforms=['crop']),
|
84 |
-
]
|
85 |
-
with gr.Column():
|
86 |
-
outputs = [gr.Gallery(label="Similar products")]
|
87 |
-
pass
|
88 |
-
# submit_btn = gr.Button("Find similar products!")
|
89 |
-
# submit_btn.click(casa_ai_run_tab3, inputs=inputs, outputs=outputs)
|
90 |
-
|
91 |
-
casa.launch()
|
|
|
1 |
+
from subprocess import call
|
2 |
+
import os
|
|
|
|
|
|
|
3 |
|
4 |
+
call(["python", os.getenv('APP_RUN_CASA')])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|