{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "531487e5-d72d-41be-b4ae-ccd9f8dc844e", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_4031598/48305459.py:16: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n", " outputs= gr.outputs.Image(type=\"pil\", label=\"hoi detection results\"),\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "Running on public URL: https://fd9d0145926e3bdb6d.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co./spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "loading annotations into memory...\n", "Done (t=1.56s)\n", "creating index...\n", "index created!\n", "\n", "[Logger] DETR Arguments:\n", "\tlr: 0.0001\n", "\tlr_backbone: 1e-05\n", "\tlr_drop: 80\n", "\tfrozen_weights: None\n", "\tbackbone: resnet50\n", "\tdilation: False\n", "\tposition_embedding: sine\n", "\tenc_layers: 6\n", "\tdec_layers: 6\n", "\tnum_queries: 100\n", "\tdataset_file: vcoco\n", "\n", "[Logger] Number of params: 52413912\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/jihwan/CPC_HOTR/hotr/models/position_encoding.py:41: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').\n", " dim_t = self.temperature ** (2 * (dim_t // 2) / self.num_pos_feats)\n" ] } ], "source": [ "import gradio as gr\n", "from transformers import pipeline\n", "from visualization import visualization\n", "# pipeline = pipeline(task=\"image-classification\", model=\"julien-c/hotdog-not-hotdog\")\n", "# pipeline = pipeline(task=\"image-classification\", model=\"jhp/hoi\")\n", "\n", "def predict(image,threshold,topk):\n", " vis_img = visualization(image,threshold,topk)\n", " return vis_img\n", "\n", "gr.Interface(\n", " predict,\n", " inputs=[gr.Image(type='pil',label=\"input image\"),\n", " gr.Slider(0, 1, value=0.4, label=\"Threshold\", info=\"Set detection score threshold between 0~1\"),\n", " gr.Number(value=5,info='Topk prediction')],\n", " outputs= gr.outputs.Image(type=\"pil\", label=\"hoi detection results\"),\n", " title=\"HOI detection\",\n", ").launch(share=True,debug=True)" ] }, { "cell_type": "code", "execution_count": 1, "id": "439a75e9-77e6-4932-9b9b-35e2d0b7a76b", "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "string indices must be integers", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[1], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m a\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msdsd\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m----> 2\u001b[0m \u001b[43ma\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43m:\u001b[49m\u001b[43m]\u001b[49m\n", "\u001b[0;31mTypeError\u001b[0m: string indices must be integers" ] } ], "source": [ "a='sdsd'\n", "a[:,:]\n" ] }, { "cell_type": "code", "execution_count": null, "id": "96fc750d-1869-4c83-87ad-d4ef909bbddb", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.17" } }, "nbformat": 4, "nbformat_minor": 5 }