Spaces:
Runtime error
Runtime error
File size: 4,776 Bytes
529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f 0bc27e7 529aa2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "531487e5-d72d-41be-b4ae-ccd9f8dc844e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7860\n",
"Running on public URL: https://fc8effa414b728bb78.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": [
"<div><iframe src=\"https://fc8effa414b728bb78.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"loading annotations into memory...\n",
"Done (t=1.67s)\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,label='Topk',info='Topk prediction')],\n",
" outputs= gr.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
}
|