Title: Example code only works for square image [bug] · Issue #34 · transformify-plugins/segmentify · GitHub
Open Graph Title: Example code only works for square image [bug] · Issue #34 · transformify-plugins/segmentify
X Title: Example code only works for square image [bug] · Issue #34 · transformify-plugins/segmentify
Description: Expected behavior segmentify should work for non-square images (width != length, ex. 512x512 is square, 511x512 is not square) Potentially relevant issues/PR #11 #13 How to reproduce the bug Below is a slightly modified version of https:...
Open Graph Description: Expected behavior segmentify should work for non-square images (width != length, ex. 512x512 is square, 511x512 is not square) Potentially relevant issues/PR #11 #13 How to reproduce the bug Below ...
X Description: Expected behavior segmentify should work for non-square images (width != length, ex. 512x512 is square, 511x512 is not square) Potentially relevant issues/PR #11 #13 How to reproduce the bug Below ...
Opengraph URL: https://github.com/transformify-plugins/segmentify/issues/34
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Example code only works for square image [bug]","articleBody":"## Expected behavior\r\n`segmentify` should work for non-square images (width != length, ex. 512x512 is square, 511x512 is not square)\r\n\r\n## Potentially relevant issues/PR\r\n#11 #13 \r\n\r\n## How to reproduce the bug\r\nBelow is a slightly modified version of https://github.com/transformify-plugins/segmentify/blob/master/examples/launch.py \r\n1. Run the code as is, popping the napari window; click `execute` button, confirm working\r\n2. Un-comment the two lines right before `napari.gui_qt`; run the code, popping the napari window, click `execute` button, and confirm it crashes\r\n```\r\nimport os\r\nimport napari\r\nfrom segmentify import segmentation\r\nimport numpy as np\r\nfrom skimage import io\r\n\r\n\r\n# parse input file\r\nexample_image = os.path.join(os.path.abspath(os.path.dirname(__file__)), \"hpa.png\")\r\nexample_labels = os.path.join(os.path.abspath(os.path.dirname(__file__)), \"hpa_labels.tif\")\r\n\r\nexample_image = io.imread(example_image)\r\nexample_labels = io.imread(example_labels)\r\n\r\n### WARNING: uncomment these two lines below to reproduce bug ###\r\n#example_image = example_image[:, 1:]\r\n#example_labels = example_labels[:, 1:]\r\n##########################################################\r\n\r\nwith napari.gui_qt():\r\n viewer = napari.Viewer()\r\n\r\n # instantiate the widget\r\n gui = segmentation.Gui()\r\n\r\n # add our new widget to the napari viewer\r\n viewer.window.add_dock_widget(gui)\r\n\r\n # keep the dropdown menus in the gui in sync with the layer model\r\n viewer.layers.events.changed.connect(lambda x: gui.refresh_choices())\r\n\r\n gui.refresh_choices()\r\n\r\n # load data\r\n viewer.add_image(example_image)\r\n viewer.add_labels(example_labels)\r\n```\r\n\r\n## Full error message\r\n```\r\nSegmenting...\r\nWARNING: Traceback (most recent call last):\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/magicgui-0.1.5-py3.8.egg/magicgui/core.py\", line 199, in \u003clambda\u003e\r\n self.call_button.clicked.connect(lambda checked: self.__call__())\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/magicgui-0.1.5-py3.8.egg/magicgui/core.py\", line 526, in __call__\r\n value = self.func(**_kwargs)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/gui.py\", line 29, in segmentation\r\n clf, features = fit(data, initial_labels.data, featurizer=featurizer.value)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/semantic/main.py\", line 129, in fit\r\n padded_features = unet_featurize(padded_image, featurizer)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/semantic/main.py\", line 59, in unet_featurize\r\n features = model(image)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/torch-1.5.1-py3.8-linux-x86_64.egg/torch/nn/modules/module.py\", line 550, in __call__\r\n result = self.forward(*input, **kwargs)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/model/unet.py\", line 57, in forward\r\n x = self.decode_4(x, skip_4)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/torch-1.5.1-py3.8-linux-x86_64.egg/torch/nn/modules/module.py\", line 550, in __call__\r\n result = self.forward(*input, **kwargs)\r\n File \"/home/hungyiwu/.venv/segmentify/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/model/layers/unet_layers.py\", line 63, in forward\r\n output += skip\r\nRuntimeError: The size of tensor a (62) must match the size of tensor b (63) at non-singleton dimension 3\r\nAborted (core dumped)\r\n```\r\n\r\n## Environment, version, and other information\r\npython 3.8.2\r\nnapari 0.3.5\r\nnapari-plugin-engine 0.1.6\r\nnapari-svg 0.1.3\r\nsegmentify 0.1.1 (installed by cloning this repo and `python setup.py install` the `master` branch)\r\nUbuntu 20.04\r\npython venv\r\n`pip freeze \u003e `[requirements.txt](https://github.com/transformify-plugins/segmentify/files/4837652/requirements.txt)\r\n","author":{"url":"https://github.com/hungyiwu","@type":"Person","name":"hungyiwu"},"datePublished":"2020-06-26T15:07:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/34/segmentify/issues/34"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4180561f-42c0-a0d7-6ad3-01226fa9213b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C77C:F07F1:AD5FBC:EEA571:698E12B7 |
| html-safe-nonce | bd3d135cf0bf7cff12e6c43a1895fce2e402e040cc258ad7722ba7936036467e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzdDOkYwN0YxOkFENUZCQzpFRUE1NzE6Njk4RTEyQjciLCJ2aXNpdG9yX2lkIjoiMjg1MDEwMjEyNTcyNzE5MTczNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b03b365315ec3554ee3d554cbbd4dc7c841a92e098056b0c5af438f5e2029244 |
| hovercard-subject-tag | issue:646327777 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/transformify-plugins/segmentify/34/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ce26afd1a8ee2c5ed6e51253b8d6961057d427b6fa884533031cd35cb04d467d/transformify-plugins/segmentify/issues/34 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ce26afd1a8ee2c5ed6e51253b8d6961057d427b6fa884533031cd35cb04d467d/transformify-plugins/segmentify/issues/34 |
| og:image:alt | Expected behavior segmentify should work for non-square images (width != length, ex. 512x512 is square, 511x512 is not square) Potentially relevant issues/PR #11 #13 How to reproduce the bug Below ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hungyiwu |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdf74c91c9ac187cc5cd7b14d4af2d6ef3e18136d002f5d36253f8538e97ee4c |
| turbo-cache-control | no-preview |
| go-import | github.com/transformify-plugins/segmentify git https://github.com/transformify-plugins/segmentify.git |
| octolytics-dimension-user_id | 51755733 |
| octolytics-dimension-user_login | transformify-plugins |
| octolytics-dimension-repository_id | 189932552 |
| octolytics-dimension-repository_nwo | transformify-plugins/segmentify |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 189932552 |
| octolytics-dimension-repository_network_root_nwo | transformify-plugins/segmentify |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1a5a3e7bbfb3486980e340c242368684156fba87 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width