Spaces:
Runtime error
Runtime error
Jaemin Cho
commited on
Commit
Β·
3612a6a
1
Parent(s):
9d658a2
Update supported objects
Browse files
app.py
CHANGED
|
@@ -19,6 +19,61 @@ from PIL import Image
|
|
| 19 |
from diffusers import StableDiffusionInpaintPipeline
|
| 20 |
from accelerate.utils import set_seed
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
class Instance:
|
| 23 |
def __init__(self, capacity = 2):
|
| 24 |
self.model_type = 'base'
|
|
@@ -247,6 +302,14 @@ def generate(task, language_instruction, grounding_texts, sketch_pad,
|
|
| 247 |
boxes = state['boxes']
|
| 248 |
grounding_texts = [x.strip() for x in grounding_texts.split(';')]
|
| 249 |
# assert len(boxes) == len(grounding_texts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
if len(boxes) != len(grounding_texts):
|
| 251 |
if len(boxes) < len(grounding_texts):
|
| 252 |
raise ValueError("""The number of boxes should be equal to the number of grounding objects.
|
|
@@ -489,6 +552,13 @@ with Blocks(
|
|
| 489 |
<p>
|
| 490 |
(1) ⌨️ Enter the object names in <em> Region Captions</em>
|
| 491 |
<br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
(2) 🖱️ Draw their corresponding bounding boxes one by one using <em> Sketch Pad</em> -- the parsed boxes will be displayed automatically.
|
| 493 |
<br>
|
| 494 |
For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/j-min/iterinpaint-CLEVR?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a>
|
|
@@ -745,6 +815,6 @@ main.launch(share=False, show_api=False, show_error=True)
|
|
| 745 |
# main.launch(
|
| 746 |
# server_name="0.0.0.0",
|
| 747 |
# share=True,
|
| 748 |
-
#
|
| 749 |
# show_api=False, show_error=True
|
| 750 |
# )
|
|
|
|
| 19 |
from diffusers import StableDiffusionInpaintPipeline
|
| 20 |
from accelerate.utils import set_seed
|
| 21 |
|
| 22 |
+
clevr_all_objects = [
|
| 23 |
+
'blue metal cube',
|
| 24 |
+
'blue metal cylinder',
|
| 25 |
+
'blue metal sphere',
|
| 26 |
+
'blue rubber cube',
|
| 27 |
+
'blue rubber cylinder',
|
| 28 |
+
'blue rubber sphere',
|
| 29 |
+
'brown metal cube',
|
| 30 |
+
'brown metal cylinder',
|
| 31 |
+
'brown metal sphere',
|
| 32 |
+
'brown rubber cube',
|
| 33 |
+
'brown rubber cylinder',
|
| 34 |
+
'brown rubber sphere',
|
| 35 |
+
'cyan metal cube',
|
| 36 |
+
'cyan metal cylinder',
|
| 37 |
+
'cyan metal sphere',
|
| 38 |
+
'cyan rubber cube',
|
| 39 |
+
'cyan rubber cylinder',
|
| 40 |
+
'cyan rubber sphere',
|
| 41 |
+
'gray metal cube',
|
| 42 |
+
'gray metal cylinder',
|
| 43 |
+
'gray metal sphere',
|
| 44 |
+
'gray rubber cube',
|
| 45 |
+
'gray rubber cylinder',
|
| 46 |
+
'gray rubber sphere',
|
| 47 |
+
'green metal cube',
|
| 48 |
+
'green metal cylinder',
|
| 49 |
+
'green metal sphere',
|
| 50 |
+
'green rubber cube',
|
| 51 |
+
'green rubber cylinder',
|
| 52 |
+
'green rubber sphere',
|
| 53 |
+
'purple metal cube',
|
| 54 |
+
'purple metal cylinder',
|
| 55 |
+
'purple metal sphere',
|
| 56 |
+
'purple rubber cube',
|
| 57 |
+
'purple rubber cylinder',
|
| 58 |
+
'purple rubber sphere',
|
| 59 |
+
'red metal cube',
|
| 60 |
+
'red metal cylinder',
|
| 61 |
+
'red metal sphere',
|
| 62 |
+
'red rubber cube',
|
| 63 |
+
'red rubber cylinder',
|
| 64 |
+
'red rubber sphere',
|
| 65 |
+
'yellow metal cube',
|
| 66 |
+
'yellow metal cylinder',
|
| 67 |
+
'yellow metal sphere',
|
| 68 |
+
'yellow rubber cube',
|
| 69 |
+
'yellow rubber cylinder',
|
| 70 |
+
'yellow rubber sphere'
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
all_clevr_colors = ['blue', 'brown', 'cyan', 'gray', 'green', 'purple', 'red', 'yellow']
|
| 74 |
+
all_clevr_materials = ['metal', 'rubber']
|
| 75 |
+
all_clevr_shapes = ['cube', 'cylinder', 'sphere']
|
| 76 |
+
|
| 77 |
class Instance:
|
| 78 |
def __init__(self, capacity = 2):
|
| 79 |
self.model_type = 'base'
|
|
|
|
| 302 |
boxes = state['boxes']
|
| 303 |
grounding_texts = [x.strip() for x in grounding_texts.split(';')]
|
| 304 |
# assert len(boxes) == len(grounding_texts)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
# check if object query is within clevr_all_objects
|
| 308 |
+
for grounding_text in grounding_texts:
|
| 309 |
+
if grounding_text not in clevr_all_objects:
|
| 310 |
+
raise ValueError("""The grounding object {} is not in the CLEVR dataset.""".format(grounding_text))
|
| 311 |
+
|
| 312 |
+
|
| 313 |
if len(boxes) != len(grounding_texts):
|
| 314 |
if len(boxes) < len(grounding_texts):
|
| 315 |
raise ValueError("""The number of boxes should be equal to the number of grounding objects.
|
|
|
|
| 552 |
<p>
|
| 553 |
(1) ⌨️ Enter the object names in <em> Region Captions</em>
|
| 554 |
<br>
|
| 555 |
+
Since the model is trained on <a href="https://cs.stanford.edu/people/jcjohns/clevr/" target="_blank">CLEVR</a> dataset, you can use the object names in the form of <b>"[color] [material] [shape]"</b> (e.g., <em>blue metal sphere</em>):
|
| 556 |
+
<br>
|
| 557 |
+
<ul>
|
| 558 |
+
<li>color: <em><color style="color: red">red</color>, <color style="color: cyan">cyan</color>, <color style="color: green">green</color>, <color style="color: blue">blue</color>, <color style="color: yellow">yellow</color>, <color style="color: purple">purple</color>, <color style="color: brown">brown</color>, <color style="color: gray">gray</color></em></li>
|
| 559 |
+
<li>material: <em>metal, rubber</em></li>
|
| 560 |
+
<li>shape: <em>cylinder, cube, sphere</em></li>
|
| 561 |
+
</ul>
|
| 562 |
(2) 🖱️ Draw their corresponding bounding boxes one by one using <em> Sketch Pad</em> -- the parsed boxes will be displayed automatically.
|
| 563 |
<br>
|
| 564 |
For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/j-min/iterinpaint-CLEVR?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a>
|
|
|
|
| 815 |
# main.launch(
|
| 816 |
# server_name="0.0.0.0",
|
| 817 |
# share=True,
|
| 818 |
+
# server_port=7899,
|
| 819 |
# show_api=False, show_error=True
|
| 820 |
# )
|