Spaces:
Runtime error
Runtime error
Try to fix shapely bug
Browse files- app.py +6 -7
- requirements.txt +58 -7
app.py
CHANGED
@@ -127,15 +127,14 @@ def prompt_with_mutation(user_prompt, fpath=None):
|
|
127 |
#Create mutated layout based on initial
|
128 |
cut_off = np.random.randint(1, 3, size=1)[0]
|
129 |
cut_off = min(cut_off, len(output)-1)
|
130 |
-
|
|
|
131 |
input_ids = tokenizer(new_prompt, return_tensors='pt')
|
132 |
-
mut_output = finetuned.generate(**input_ids, do_sample=True, top_p=0.94, top_k=100, max_length=
|
133 |
mut_output = tokenizer.batch_decode(mut_output, skip_special_tokens=True)
|
134 |
mut_im = mut_txt2layout(mut_output)
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
return im, mut_im
|
139 |
|
140 |
# Gradio App
|
141 |
|
@@ -143,7 +142,7 @@ def gen_and_mutate(user_prompt, mutate=False):
|
|
143 |
if(mutate):
|
144 |
im, mut_im = None, None
|
145 |
while (mut_im is None):
|
146 |
-
im, mut_im = prompt_with_mutation(user_prompt)
|
147 |
else:
|
148 |
mut_im=Image.open(r"C:\\Users\\user\\Desktop\\empty.png")
|
149 |
im, _ = prompt_to_layout(user_prompt)
|
@@ -162,7 +161,7 @@ iface = gr.Interface(fn=gen_and_mutate, inputs=[textbox, checkbox], outputs=[gen
|
|
162 |
article='''<div>
|
163 |
<p> This app allows users the use of natural language prompts for appartment layout generation, using a variety of semantic information:</p>
|
164 |
<ul>
|
165 |
-
<li> <strong>typology</strong>: "a
|
166 |
<li> <strong>enumeration</strong>: "a house with five rooms"</li>
|
167 |
<li> <strong>adjacency</strong>: "the kitchen is adjacent to a bedroom", "the living room is not adjacent to the bathroom"</li>
|
168 |
<li> <strong>location</strong>: "a house with a bedroom in the north east side"</li>
|
|
|
127 |
#Create mutated layout based on initial
|
128 |
cut_off = np.random.randint(1, 3, size=1)[0]
|
129 |
cut_off = min(cut_off, len(output)-1)
|
130 |
+
to_keep = ', '.join(output[:cut_off]) + ', '
|
131 |
+
new_prompt = '[User prompt] {} [Layout] {}'.format(user_prompt, to_keep)
|
132 |
input_ids = tokenizer(new_prompt, return_tensors='pt')
|
133 |
+
mut_output = finetuned.generate(**input_ids, do_sample=True, top_p=0.94, top_k=100, max_length=300)
|
134 |
mut_output = tokenizer.batch_decode(mut_output, skip_special_tokens=True)
|
135 |
mut_im = mut_txt2layout(mut_output)
|
136 |
|
137 |
+
return im, mut_im, output, mut_output
|
|
|
|
|
138 |
|
139 |
# Gradio App
|
140 |
|
|
|
142 |
if(mutate):
|
143 |
im, mut_im = None, None
|
144 |
while (mut_im is None):
|
145 |
+
im, mut_im, output, mut_output = prompt_with_mutation(user_prompt)
|
146 |
else:
|
147 |
mut_im=Image.open(r"C:\\Users\\user\\Desktop\\empty.png")
|
148 |
im, _ = prompt_to_layout(user_prompt)
|
|
|
161 |
article='''<div>
|
162 |
<p> This app allows users the use of natural language prompts for appartment layout generation, using a variety of semantic information:</p>
|
163 |
<ul>
|
164 |
+
<li> <strong>typology</strong>: "a house with two bedrooms and two bathrooms"</li>
|
165 |
<li> <strong>enumeration</strong>: "a house with five rooms"</li>
|
166 |
<li> <strong>adjacency</strong>: "the kitchen is adjacent to a bedroom", "the living room is not adjacent to the bathroom"</li>
|
167 |
<li> <strong>location</strong>: "a house with a bedroom in the north east side"</li>
|
requirements.txt
CHANGED
@@ -1,8 +1,59 @@
|
|
1 |
-
numpy>=1.16.4
|
2 |
-
textwrap3==0.9.2
|
3 |
-
Pillow==8.0.1
|
4 |
-
transformers==4.8.0
|
5 |
-
gradio>=2.0.7
|
6 |
-
shapely==1.7.1
|
7 |
aggdraw==1.3.12
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
aggdraw==1.3.12
|
2 |
+
analytics-python==1.4.0
|
3 |
+
backoff==1.10.0
|
4 |
+
bcrypt==3.2.0
|
5 |
+
certifi==2021.5.30
|
6 |
+
cffi==1.14.6
|
7 |
+
charset-normalizer==2.0.3
|
8 |
+
click==8.0.1
|
9 |
+
colorama==0.4.4
|
10 |
+
cryptography==3.4.7
|
11 |
+
cycler==0.10.0
|
12 |
+
ffmpy==0.3.0
|
13 |
+
filelock==3.0.12
|
14 |
+
Flask==2.0.1
|
15 |
+
Flask-CacheBuster==1.0.0
|
16 |
+
Flask-Cors==3.0.10
|
17 |
+
Flask-Login==0.5.0
|
18 |
+
gradio==2.2.2
|
19 |
+
huggingface-hub==0.0.12
|
20 |
+
idna==3.2
|
21 |
+
itsdangerous==2.0.1
|
22 |
+
Jinja2==3.0.1
|
23 |
+
joblib==1.0.1
|
24 |
+
kiwisolver==1.3.1
|
25 |
+
markdown2==2.4.0
|
26 |
+
MarkupSafe==2.0.1
|
27 |
+
matplotlib==3.4.2
|
28 |
+
monotonic==1.6
|
29 |
+
numpy==1.21.1
|
30 |
+
packaging==21.0
|
31 |
+
pandas==1.3.0
|
32 |
+
paramiko==2.7.2
|
33 |
+
Pillow==8.3.1
|
34 |
+
pip==21.1.3
|
35 |
+
pycparser==2.20
|
36 |
+
pycryptodome==3.10.1
|
37 |
+
PyNaCl==1.4.0
|
38 |
+
pyparsing==2.4.7
|
39 |
+
python-dateutil==2.8.2
|
40 |
+
pytz==2021.1
|
41 |
+
PyYAML==5.4.1
|
42 |
+
regex==2021.7.6
|
43 |
+
requests==2.26.0
|
44 |
+
sacremoses==0.0.45
|
45 |
+
scipy==1.7.0
|
46 |
+
setuptools==52.0.0.post20210125
|
47 |
+
Shapely==1.7.1
|
48 |
+
six==1.16.0
|
49 |
+
tokenizers==0.10.3
|
50 |
+
torch==1.9.0+cu102
|
51 |
+
torchaudio==0.9.0
|
52 |
+
torchvision==0.10.0+cu102
|
53 |
+
tqdm==4.61.2
|
54 |
+
transformers==4.8.2
|
55 |
+
typing-extensions==3.10.0.0
|
56 |
+
urllib3==1.26.6
|
57 |
+
Werkzeug==2.0.1
|
58 |
+
wheel==0.36.2
|
59 |
+
wincertstore==0.2
|