Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from pathlib import Path
|
|
|
2 |
import numpy as np
|
3 |
import random
|
4 |
import re
|
@@ -21,6 +22,12 @@ finetuned = finetuned.to(device)
|
|
21 |
|
22 |
# Utility functions
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
|
25 |
"balcony": 7, "corridor": 8, "dining_room": 9, "laundry_room": 10}
|
26 |
|
@@ -67,7 +74,12 @@ def draw_polygons(polygons, colors, im_size=(256, 256), b_color="white", fpath=N
|
|
67 |
return draw, image
|
68 |
|
69 |
def prompt_to_layout(user_prompt, top_p, top_k, fpath=None):
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
model_prompt = '[User prompt] {} [Layout]'.format(user_prompt)
|
72 |
#print(model_prompt)
|
73 |
input_ids = tokenizer(model_prompt, return_tensors='pt').to(device)
|
|
|
1 |
from pathlib import Path
|
2 |
+
from num2words import num2words
|
3 |
import numpy as np
|
4 |
import random
|
5 |
import re
|
|
|
22 |
|
23 |
# Utility functions
|
24 |
|
25 |
+
def containsNumber(value):
|
26 |
+
for character in value:
|
27 |
+
if character.isdigit():
|
28 |
+
return True
|
29 |
+
return False
|
30 |
+
|
31 |
housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
|
32 |
"balcony": 7, "corridor": 8, "dining_room": 9, "laundry_room": 10}
|
33 |
|
|
|
74 |
return draw, image
|
75 |
|
76 |
def prompt_to_layout(user_prompt, top_p, top_k, fpath=None):
|
77 |
+
|
78 |
+
if(containsNumber(user_prompt) == True):
|
79 |
+
spaced_prompt = user_prompt.split(' ')
|
80 |
+
new_prompt = ' '.join([word if word.isdigit() == False else num2words(int(word)).lower() for word in spaced_prompt])
|
81 |
+
model_prompt = '[User prompt] {} [Layout]'.format(new_prompt)
|
82 |
+
|
83 |
model_prompt = '[User prompt] {} [Layout]'.format(user_prompt)
|
84 |
#print(model_prompt)
|
85 |
input_ids = tokenizer(model_prompt, return_tensors='pt').to(device)
|