Spaces:
Build error
Build error
Commit
·
9502fe9
1
Parent(s):
8d9c823
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,14 +113,14 @@ def inference(img,unique_only):
|
|
| 113 |
"h": int(height),
|
| 114 |
}
|
| 115 |
)
|
| 116 |
-
if ((not unique_only) or (
|
| 117 |
object_list_str.append(
|
| 118 |
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width: {int(width)} Height: {int(height)}"
|
| 119 |
)
|
| 120 |
unique_object_dict[predicted_label] = 1
|
| 121 |
|
| 122 |
|
| 123 |
-
output_str = "Imagine you are
|
| 124 |
for line in object_list_str:
|
| 125 |
output_str += line + "\n"
|
| 126 |
|
|
@@ -131,7 +131,7 @@ def inference(img,unique_only):
|
|
| 131 |
|
| 132 |
|
| 133 |
with gr.Blocks() as demo:
|
| 134 |
-
gr.Markdown("# Detic+ChatGPT")
|
| 135 |
gr.Markdown("Use Detic to detect objects in an image and then copy/paste into ChatGPT playground to describe the image.")
|
| 136 |
|
| 137 |
#gr.HTML("<p>You can duplicating this space and use your own session token: <a style='display:inline-block' href='https://huggingface.co/spaces/yizhangliu/chatGPT?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>")
|
|
@@ -139,12 +139,13 @@ with gr.Blocks() as demo:
|
|
| 139 |
|
| 140 |
with gr.Column():
|
| 141 |
inp = gr.Image(label="Input Image", type="filepath")
|
|
|
|
| 142 |
btn_detic = gr.Button("Run Detic+ChatGPT")
|
| 143 |
with gr.Column():
|
| 144 |
outviz = gr.Image(label="Visualization", type="pil")
|
| 145 |
output_desc = gr.Textbox(label="Description for using in ChatGPT", lines=5)
|
| 146 |
# outputjson = gr.JSON(label="Detected Objects")
|
| 147 |
|
| 148 |
-
btn_detic.click(fn=inference, inputs=[inp,
|
| 149 |
|
| 150 |
demo.launch()
|
|
|
|
| 113 |
"h": int(height),
|
| 114 |
}
|
| 115 |
)
|
| 116 |
+
if ((not unique_only) or (unique_only and predicted_label not in unique_object_dict)):
|
| 117 |
object_list_str.append(
|
| 118 |
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width: {int(width)} Height: {int(height)}"
|
| 119 |
)
|
| 120 |
unique_object_dict[predicted_label] = 1
|
| 121 |
|
| 122 |
|
| 123 |
+
output_str = "Imagine you are a blind but intelligent image captioner who is only given the X,Y coordinates and width, height of each object in a scene with no specific attributes of the objects themselves. Create a description of the scene using the relative positions and sizes of objects\n"
|
| 124 |
for line in object_list_str:
|
| 125 |
output_str += line + "\n"
|
| 126 |
|
|
|
|
| 131 |
|
| 132 |
|
| 133 |
with gr.Blocks() as demo:
|
| 134 |
+
gr.Markdown("# Detic+ChatGPT <i>A duplicated tweak of <a href=\"https://huggingface.co/spaces/taesiri/DeticChatGPT\">taesiri's Dectic/ChatGPT demo</a></i>")
|
| 135 |
gr.Markdown("Use Detic to detect objects in an image and then copy/paste into ChatGPT playground to describe the image.")
|
| 136 |
|
| 137 |
#gr.HTML("<p>You can duplicating this space and use your own session token: <a style='display:inline-block' href='https://huggingface.co/spaces/yizhangliu/chatGPT?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>")
|
|
|
|
| 139 |
|
| 140 |
with gr.Column():
|
| 141 |
inp = gr.Image(label="Input Image", type="filepath")
|
| 142 |
+
chk = gr.Checkbox(label="Unique Object only?")
|
| 143 |
btn_detic = gr.Button("Run Detic+ChatGPT")
|
| 144 |
with gr.Column():
|
| 145 |
outviz = gr.Image(label="Visualization", type="pil")
|
| 146 |
output_desc = gr.Textbox(label="Description for using in ChatGPT", lines=5)
|
| 147 |
# outputjson = gr.JSON(label="Detected Objects")
|
| 148 |
|
| 149 |
+
btn_detic.click(fn=inference, inputs=[inp,chk], outputs=[outviz, output_desc])
|
| 150 |
|
| 151 |
demo.launch()
|