Spaces:
Build error
Build error
Commit ·
58c3691
1
Parent(s): dba80c8
Update app.py
Browse files126 unmodified lines1271281291301311321332 unmodified lines1361371381391401411421 unmodified line1441451461471481491501 unmodified line152153154155156157158126 unmodified lines})object_list_str.append(f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width {int(width)} Height: {int(height)}\n")#chat_gpt_response = get_response_from_chatbot(2 unmodified linesreturn (Image.fromarray(np.uint8(out.get_image())).convert("RGB"),f"You are an intelligent image captioner. I will hand you the objects and their position, and you should give me a detailed description for the photo. In this photo we have the following objects\n{object_list_str}")1 unmodified linegr.Markdown("# Detic+ChatGPT")gr.Markdown("Use Detic to detect objects in an image and then use ChatGPT to describe the image.")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>")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>")with gr.Column():1 unmodified linebtn_detic = gr.Button("Run Detic+ChatGPT")with gr.Column():outviz = gr.Image(label="Visualization", type="pil")output_desc = gr.Textbox(label="chatGPT Description", lines=5)# outputjson = gr.JSON(label="Detected Objects")btn_detic.click(fn=inference, inputs=inp, outputs=[outviz, output_desc])126 unmodified lines1271281291301311321332 unmodified lines1361371381391401411421 unmodified line1441451461471481491501 unmodified line152153154155156157158126 unmodified lines})object_list_str.append(f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width {int(width)} Height: {int(height)}<br/>")#chat_gpt_response = get_response_from_chatbot(2 unmodified linesreturn (Image.fromarray(np.uint8(out.get_image())).convert("RGB"),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}")1 unmodified linegr.Markdown("# Detic+ChatGPT")gr.Markdown("Use Detic to detect objects in an image and then use ChatGPT to describe the image.")#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>")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>")with gr.Column():1 unmodified linebtn_detic = gr.Button("Run Detic+ChatGPT")with gr.Column():outviz = gr.Image(label="Visualization", type="pil")output_desc = gr.Textbox(label="Description for using in ChatGPT", lines=5)# outputjson = gr.JSON(label="Detected Objects")btn_detic.click(fn=inference, inputs=inp, outputs=[outviz, output_desc])
app.py+4-4