Spaces:
Build error
Build error
Commit
·
58c3691
1
Parent(s):
dba80c8
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,7 +127,7 @@ def inference(img):
|
|
| 127 |
}
|
| 128 |
)
|
| 129 |
object_list_str.append(
|
| 130 |
-
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width {int(width)} Height: {int(height)}
|
| 131 |
)
|
| 132 |
|
| 133 |
#chat_gpt_response = get_response_from_chatbot(
|
|
@@ -136,7 +136,7 @@ def inference(img):
|
|
| 136 |
|
| 137 |
return (
|
| 138 |
Image.fromarray(np.uint8(out.get_image())).convert("RGB"),
|
| 139 |
-
f"
|
| 140 |
)
|
| 141 |
|
| 142 |
|
|
@@ -144,7 +144,7 @@ with gr.Blocks() as demo:
|
|
| 144 |
gr.Markdown("# Detic+ChatGPT")
|
| 145 |
gr.Markdown("Use Detic to detect objects in an image and then use ChatGPT to describe the image.")
|
| 146 |
|
| 147 |
-
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>")
|
| 148 |
gr.HTML("<p> Instruction on how to get session token can be seen in video <a style='display:inline-block' href='https://www.youtube.com/watch?v=TdNSj_qgdFk'><font style='color:blue;weight:bold;'>here</font></a>. Add your session token by going to settings and add under secrets. </p>")
|
| 149 |
|
| 150 |
with gr.Column():
|
|
@@ -152,7 +152,7 @@ with gr.Blocks() as demo:
|
|
| 152 |
btn_detic = gr.Button("Run Detic+ChatGPT")
|
| 153 |
with gr.Column():
|
| 154 |
outviz = gr.Image(label="Visualization", type="pil")
|
| 155 |
-
output_desc = gr.Textbox(label="
|
| 156 |
# outputjson = gr.JSON(label="Detected Objects")
|
| 157 |
|
| 158 |
btn_detic.click(fn=inference, inputs=inp, outputs=[outviz, output_desc])
|
|
|
|
| 127 |
}
|
| 128 |
)
|
| 129 |
object_list_str.append(
|
| 130 |
+
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width {int(width)} Height: {int(height)}<br/>"
|
| 131 |
)
|
| 132 |
|
| 133 |
#chat_gpt_response = get_response_from_chatbot(
|
|
|
|
| 136 |
|
| 137 |
return (
|
| 138 |
Image.fromarray(np.uint8(out.get_image())).convert("RGB"),
|
| 139 |
+
f"Imagine you are an intelligent image captioner. For each object in a scene the X, Y coordinates and width, height are given below. Use them to describe in detail each object in the scene. In the end give an overall summary of scene\n{object_list_str}"
|
| 140 |
)
|
| 141 |
|
| 142 |
|
|
|
|
| 144 |
gr.Markdown("# Detic+ChatGPT")
|
| 145 |
gr.Markdown("Use Detic to detect objects in an image and then use ChatGPT to describe the image.")
|
| 146 |
|
| 147 |
+
#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>")
|
| 148 |
gr.HTML("<p> Instruction on how to get session token can be seen in video <a style='display:inline-block' href='https://www.youtube.com/watch?v=TdNSj_qgdFk'><font style='color:blue;weight:bold;'>here</font></a>. Add your session token by going to settings and add under secrets. </p>")
|
| 149 |
|
| 150 |
with gr.Column():
|
|
|
|
| 152 |
btn_detic = gr.Button("Run Detic+ChatGPT")
|
| 153 |
with gr.Column():
|
| 154 |
outviz = gr.Image(label="Visualization", type="pil")
|
| 155 |
+
output_desc = gr.Textbox(label="Description for using in ChatGPT", lines=5)
|
| 156 |
# outputjson = gr.JSON(label="Detected Objects")
|
| 157 |
|
| 158 |
btn_detic.click(fn=inference, inputs=inp, outputs=[outviz, output_desc])
|