Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] query viz func add #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions utils/viewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,66 @@
}
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"def query_viz(query, n_rows, n_cols, image_mode = False):\n",
" items = [set() for _ in range(n_cols)]\n",
" if image_mode:\n",
" # image mode\n",
Copy link
Contributor

@jaehwan-AI jaehwan-AI Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 에러가 있는데 if문의 실행이 정의되어 있지 않습니다.
의도하신 부분일까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 부분이 image 단위로 출력하는 부분인데, 구현에 어려움이 있어서 도움을 요청하였습니다 ~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도움을 요청한 부분이었군요. 확인해보겠습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네, 감사합니다!

" else:\n",
" pick = query.groupby('category_id').sample(n_rows*2, replace=True)[['id', 'image_id', 'category_id', 'category_name', 'X', 'Y', 'W', 'H']].values.tolist()\n",
"\n",
" for obj in pick:\n",
" if len(items[obj[2]]) >= n_rows: continue\n",
" items[obj[2]].add(tuple(obj))\n",
" max_len = 0\n",
" for item in items:\n",
" max_len = max(max_len,len(item))\n",
"\n",
" fig, axes = plt.subplots(max_len, n_cols, sharex=False, sharey=False, figsize=(30, 32))\n",
" fig.suptitle(f\"{label_name}\", fontsize=28)\n",
"\n",
" for col in range(n_cols):\n",
" for row, (obj_id, img_id, label, name, x, y, w, h) in enumerate(items[col]):\n",
" y, x, h, w = int(x), int(y), int(w), int(h)\n",
" image, target, image_id = single_view_dataset[img_id]\n",
" if w > 1 and h > 1:\n",
" axes[row, col].imshow(image[x:x+w+1,y:y+h+1,:])\n",
" axes[row, col].set_title(f\"[{img_id:0>4d}.jpg/{obj_id}], [{h},{w}]\", fontsize=10)\n",
" # axes[row, col].set_title(f\"[{pick:0>4d}.jpg/{object_pick}] [{label}]{name} ({w},{h})\", fontsize=24)\n",
" axes[row, col].axis('off')\n",
"\n",
" plt.tight_layout(rect=[0, 0, 1, 0.97])\n",
" plt.show()"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"n_rows = 10\n",
"query = df[df['X'] < 5] \n",
"num_class = 10\n",
"query_viz(query, n_rows, num_class)"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"n_rows, num_class = 10, 10\n",
"query = df[(df['W'] < 10) & (df['W'] > 0)] \n",
"query_viz(query, n_rows, num_class)"
],
"outputs": [],
"metadata": {}
}
],
"metadata": {
Expand Down