Spaces:
Runtime error
Runtime error
Better results.
Browse files- app.py +6 -5
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -10,10 +10,11 @@ from shapely.geometry.polygon import Polygon
|
|
| 10 |
from shapely.affinity import scale
|
| 11 |
from PIL import Image, ImageDraw, ImageOps, ImageFilter, ImageFont, ImageColor
|
| 12 |
|
| 13 |
-
os.system('pip3 install gradio==
|
| 14 |
import gradio as gr
|
| 15 |
|
| 16 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM
|
|
|
|
| 17 |
|
| 18 |
tokenizer = AutoTokenizer.from_pretrained("architext/gptj-162M")
|
| 19 |
finetuned = AutoModelForCausalLM.from_pretrained("architext/gptj-162M")
|
|
@@ -44,7 +45,7 @@ def creativity(intensity):
|
|
| 44 |
|
| 45 |
housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
|
| 46 |
"balcony": 7, "corridor": 8, "dining_room": 9, "laundry_room": 10}
|
| 47 |
-
|
| 48 |
architext_colors = [[0, 0, 0], [249, 222, 182], [195, 209, 217], [250, 120, 128], [126, 202, 234], [190, 0, 198], [255, 255, 255],
|
| 49 |
[6, 53, 17], [17, 33, 58], [132, 151, 246], [197, 203, 159], [6, 53, 17],]
|
| 50 |
|
|
@@ -116,8 +117,8 @@ def prompt_to_layout(user_prompt, intensity, fpath=None):
|
|
| 116 |
geom = []
|
| 117 |
for poly in polygons:
|
| 118 |
scaled_poly = scale(Polygon(np.array(poly, dtype=int)), xfact=2, yfact=2, origin=(0,0))
|
| 119 |
-
geom.append(scaled_poly)
|
| 120 |
-
colors = [architext_colors[housegan_labels[space]] for space in spaces]
|
| 121 |
_, im = draw_polygons(geom, colors, fpath=fpath)
|
| 122 |
html = '<img class="labels" src="images/labels.png" />'
|
| 123 |
legend = Image.open("labels.png")
|
|
@@ -253,7 +254,7 @@ custom_css="""
|
|
| 253 |
creative_slider = gr.inputs.Radio(["Low", "Medium", "High"], default="Low", label='Creativity')
|
| 254 |
textbox = gr.inputs.Textbox(placeholder='An apartment with two bedrooms and one bathroom', lines="3",
|
| 255 |
label="DESCRIBE YOUR IDEAL APARTMENT")
|
| 256 |
-
generated = gr.outputs.Image(label='Generated Layout')
|
| 257 |
layout = gr.outputs.Textbox(label='Layout Coordinates')
|
| 258 |
|
| 259 |
iface = gr.Interface(fn=prompt_to_layout, inputs=[textbox, creative_slider],
|
|
|
|
| 10 |
from shapely.affinity import scale
|
| 11 |
from PIL import Image, ImageDraw, ImageOps, ImageFilter, ImageFont, ImageColor
|
| 12 |
|
| 13 |
+
os.system('pip3 install gradio==3.14.0')
|
| 14 |
import gradio as gr
|
| 15 |
|
| 16 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM
|
| 17 |
+
from transformers.models.gptj.modeling_gptj import apply_rotary_pos_emb as apply_rotary_pos_emb_pt
|
| 18 |
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained("architext/gptj-162M")
|
| 20 |
finetuned = AutoModelForCausalLM.from_pretrained("architext/gptj-162M")
|
|
|
|
| 45 |
|
| 46 |
housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
|
| 47 |
"balcony": 7, "corridor": 8, "dining_room": 9, "laundry_room": 10}
|
| 48 |
+
default_color = [128, 128, 128]
|
| 49 |
architext_colors = [[0, 0, 0], [249, 222, 182], [195, 209, 217], [250, 120, 128], [126, 202, 234], [190, 0, 198], [255, 255, 255],
|
| 50 |
[6, 53, 17], [17, 33, 58], [132, 151, 246], [197, 203, 159], [6, 53, 17],]
|
| 51 |
|
|
|
|
| 117 |
geom = []
|
| 118 |
for poly in polygons:
|
| 119 |
scaled_poly = scale(Polygon(np.array(poly, dtype=int)), xfact=2, yfact=2, origin=(0,0))
|
| 120 |
+
geom.append(scaled_poly)
|
| 121 |
+
colors = [architext_colors[housegan_labels[space]] if space in housegan_labels else default_color for space in spaces]
|
| 122 |
_, im = draw_polygons(geom, colors, fpath=fpath)
|
| 123 |
html = '<img class="labels" src="images/labels.png" />'
|
| 124 |
legend = Image.open("labels.png")
|
|
|
|
| 254 |
creative_slider = gr.inputs.Radio(["Low", "Medium", "High"], default="Low", label='Creativity')
|
| 255 |
textbox = gr.inputs.Textbox(placeholder='An apartment with two bedrooms and one bathroom', lines="3",
|
| 256 |
label="DESCRIBE YOUR IDEAL APARTMENT")
|
| 257 |
+
generated = gr.outputs.Image(label='Generated Layout', type='numpy')
|
| 258 |
layout = gr.outputs.Textbox(label='Layout Coordinates')
|
| 259 |
|
| 260 |
iface = gr.Interface(fn=prompt_to_layout, inputs=[textbox, creative_slider],
|
requirements.txt
CHANGED
|
@@ -3,7 +3,7 @@ numpy
|
|
| 3 |
torch
|
| 4 |
shapely
|
| 5 |
pillow
|
| 6 |
-
gradio==
|
| 7 |
jinja2
|
| 8 |
-
git+https://github.com/
|
| 9 |
accelerate>=0.20.3
|
|
|
|
| 3 |
torch
|
| 4 |
shapely
|
| 5 |
pillow
|
| 6 |
+
gradio==3.14.0
|
| 7 |
jinja2
|
| 8 |
+
git+https://github.com/huggingface/transformers@423d087ffd591158c7d8eecda211041bb907c658
|
| 9 |
accelerate>=0.20.3
|