From a28e75c9446fd1fcd880f8d10bb653ffc4835d3b Mon Sep 17 00:00:00 2001 From: esgomezm Date: Fri, 10 May 2024 20:29:42 +0200 Subject: [PATCH] remove temporal files --- .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 - .../requirements-checkpoint.txt | 7 - .../KaibuInterface-checkpoint.ipynb | 273 ------------------ .../prepare_data-checkpoint.py | 28 -- ...imageio-colab-client.imjoy-checkpoint.html | 90 ------ 5 files changed, 404 deletions(-) delete mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb delete mode 100644 .ipynb_checkpoints/requirements-checkpoint.txt delete mode 100644 notebooks/.ipynb_checkpoints/KaibuInterface-checkpoint.ipynb delete mode 100644 notebooks/.ipynb_checkpoints/prepare_data-checkpoint.py delete mode 100644 plugins/.ipynb_checkpoints/bioimageio-colab-client.imjoy-checkpoint.html diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb deleted file mode 100644 index 363fcab..0000000 --- a/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/.ipynb_checkpoints/requirements-checkpoint.txt b/.ipynb_checkpoints/requirements-checkpoint.txt deleted file mode 100644 index 4755e13..0000000 --- a/.ipynb_checkpoints/requirements-checkpoint.txt +++ /dev/null @@ -1,7 +0,0 @@ -numpy==1.26.4 -imjoy-rpc==0.5.48.post2 -requests==2.31.0 -kaibu-utils==0.1.14 -tifffile -matplotlib -imjoy-jupyter-extension diff --git a/notebooks/.ipynb_checkpoints/KaibuInterface-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/KaibuInterface-checkpoint.ipynb deleted file mode 100644 index ca9c09c..0000000 --- a/notebooks/.ipynb_checkpoints/KaibuInterface-checkpoint.ipynb +++ /dev/null @@ -1,273 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 3, - "id": "69ebb748-9189-4443-a427-913d3a5ee6ce", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "https://imjoy.io/lite?plugin=https://raw.githubusercontent.com/bioimage-io/bioimageio-colab/main/plugins/bioimageio-colab-client.imjoy.html\n" - ] - } - ], - "source": [ - "import os\n", - "from imjoy_rpc.hypha import connect_to_server\n", - "import numpy as np\n", - "# Prepare paths for output\n", - "from tifffile import imread, imsave\n", - "from kaibu_utils import fetch_image, features_to_mask\n", - "\n", - "path2data = \"/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/u2os-leica-collective-cropped\"\n", - "outpath = \"/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/kaibu_output\"\n", - "os.makedirs(outpath, exist_ok=True)\n", - "\n", - "training_images = []\n", - "async def start_server(server_url,path2data, outpath):\n", - "\n", - " path2label = os.path.join(outpath, \"labels\")\n", - " os.makedirs(path2label, exist_ok=True)\n", - " \n", - " path2source = os.path.join(outpath, \"source\")\n", - " os.makedirs(path2source, exist_ok=True)\n", - " # Connect to the server link\n", - " server = await connect_to_server({\"server_url\": server_url})\n", - " # When multiple people open the link above, they can join a common workspace as an ImJoy client\n", - " def add_image(image, label):\n", - " training_images.append((image, label))\n", - " print(f\"{len(training_images)} available already.\")\n", - " return\n", - " \n", - " def get_random_image():\n", - " filenames = [f for f in os.listdir(path2data) if f.endswith(\".tif\")]\n", - " n = np.random.randint(len(filenames)-1)\n", - " image = imread(os.path.join(path2data, filenames[n]))\n", - " #print(image.shape)\n", - " new_filename = f\"{len(os.listdir(path2source)) + 1}_{filenames[n]}\"\n", - " \n", - "\n", - " return image, filenames[n], new_filename, \n", - " \n", - " def save_annotation(filename, newname, features, image_shape):\n", - " mask = features_to_mask(features, image_shape)\n", - " image = imread(os.path.join(path2data, filename))\n", - " imsave(os.path.join(path2source, newname), image)\n", - " imsave(os.path.join(path2label, newname), mask)\n", - " \n", - " \n", - " await server.register_service({\n", - " \"name\": \"Model Trainer\",\n", - " \"id\": \"biocolab\",\n", - " \"config\": {\n", - " \"visibility\": \"public\"\n", - " },\n", - " \"get_random_image\": get_random_image,\n", - " \"save_annotation\": save_annotation,\n", - " \n", - " })\n", - "\n", - " print(\"https://imjoy.io/lite?plugin=https://raw.githubusercontent.com/bioimage-io/bioimageio-colab/main/plugins/bioimageio-colab-client.imjoy.html\")\n", - "\n", - "\n", - "server_url = \"https://ai.imjoy.io\"\n", - "await start_server(server_url, path2data, outpath)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "791f0a53-20aa-4086-a2a5-03781153aea6", - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "# from imjoy import api\n", - "# from kaibu_utils import fetch_image, features_to_mask, mask_to_features\n", - "# import os\n", - "# from imjoy_rpc.hypha import connect_to_server\n", - "# import numpy as np\n", - "# # Prepare paths for output\n", - "# from tifffile import imread, imsave\n", - "\n", - "# path2data = \"/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/train/\"\n", - "# outpath = \"/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/kaibu_output\"\n", - "# os.makedirs(outpath, exist_ok=True)\n", - "# path2label = os.path.join(outpath, \"labels\")\n", - "# os.makedirs(path2label, exist_ok=True)\n", - "# path2source = os.path.join(outpath, \"source\")\n", - "# os.makedirs(path2source, exist_ok=True)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "3ab55eee-9bf6-416d-a685-11df4e38640d", - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "window.connectPlugin && window.connectPlugin(\"437ae38b-316c-4401-8b44-108097a84d7a\")" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "<_GatheringFuture pending>" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from imjoy_rpc import api\n", - "from imjoy_rpc.hypha import connect_to_server\n", - "\n", - "class BioImageIOCrowdSourcing():\n", - " def __init__(self):\n", - " self.image = None\n", - " self.mask = None\n", - " self.filename = None\n", - " self.newname = None\n", - " self.mask_id = None\n", - " self.image_id = None\n", - " self.annotation_layer = None\n", - "\n", - " async def setup(self):\n", - " viewer = await api.createWindow(src=\"https://kaibu.org/#/app\", fullscreen=True)\n", - " await api.showMessage(\"Connecting to server....\")\n", - " server = await connect_to_server({\"server_url\": \"https://ai.imjoy.io\"})\n", - " self.biocolab = await server.get_service(\"biocolab\")\n", - "\n", - " ## Define image reading and displaying function\n", - " async def get_image():\n", - " \n", - " if self.image is not None:\n", - " await viewer.remove_layer({\"id\": self.image_id.id})\n", - " await viewer.remove_layer({\"id\": self.annotation_layer.id})\n", - " \n", - " self.image, self.filename, self.newname = await self.biocolab.get_random_image()\n", - " self.image_id = await viewer.view_image(\n", - " self.image,\n", - " name=\"image\")\n", - " # Add the little annotation functionality to the interface\n", - " self.annotation_layer = await viewer.add_shapes(\n", - " [],\n", - " shape_type=\"polygon\",\n", - " draw_edge_color=\"magenta\",\n", - " name=\"annotation\",\n", - " )\n", - " \n", - " ## Define image annotation printing into a mask with the name \"mask\"\n", - " # async def create_mask():\n", - " # self.features = await self.annotation_layer.get_features()\n", - " # if self.mask is not None:\n", - " # await viewer.remove_layer({\"id\": self.mask_id.id})\n", - " \n", - " # self.mask = features_to_mask(self.features, [self.image.shape[0], self.image.shape[1]])\n", - " # self.mask_id = await viewer.view_image(\n", - " # self.mask,\n", - " # name=\"mask\"\n", - " # )\n", - " # await api.showMessage(\"Mask created\")\n", - " \n", - " async def save_annotation():\n", - " self.features = await self.annotation_layer.get_features()\n", - " await self.biocolab.save_annotation(self.filename, self.newname, self.features, [self.image.shape[0], self.image.shape[1]])\n", - " await api.showMessage(\"Annotation Saved to \" + self.filename)\n", - " \n", - " async def select_option(option):\n", - " if option == \"Get Image\":\n", - " await get_image()\n", - " elif option == \"Save Annotations\":\n", - " await save_annotation() \n", - " \n", - "\n", - " await viewer.add_widget(\n", - " {\n", - " \"_rintf\": True,\n", - " \"name\": \"Control\",\n", - " \"type\": \"control\",\n", - " \"elements\": [\n", - " {\n", - " \"type\": \"dropdown\",\n", - " \"label\": \"Options\",\n", - " \"options\": [\"Get Image\", \"Save Annotations\"],\n", - " \"callback\": select_option,\n", - " }\n", - " ],\n", - " })\n", - "\n", - " await api.showMessage(\"Redy to annotate!\")\n", - "\n", - "api.export(BioImageIOCrowdSourcing())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b6dcd74f-7007-47bf-a844-5785b5a12e99", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - " \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c3fbf878-0818-4c15-b029-7a45f88a4df5", - "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.10.0" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/notebooks/.ipynb_checkpoints/prepare_data-checkpoint.py b/notebooks/.ipynb_checkpoints/prepare_data-checkpoint.py deleted file mode 100644 index 398b899..0000000 --- a/notebooks/.ipynb_checkpoints/prepare_data-checkpoint.py +++ /dev/null @@ -1,28 +0,0 @@ -from tifffile import imread, imsave -import numpy as np -import os - - -path2data = "/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/u2os-leica-collective/" -outpath = "/Users/esti/Documents/PROYECTOS/BIOIMAGEIO/bioimageio-colab/data/u2os-leica-collective-cropped" -os.makedirs(outpath, exist_ok=True) -import cv2 -files = [f for f in os.listdir(path2data) if f.endswith(".tif")] -size = 512 -resize = 0.25 -for f in files: - k = 0 - im = imread(os.path.join(path2data, f)) - h = im.shape[0] - w = im.shape[1] - print(f"old:{w},{h}") - w = np.int16(np.round(w*resize)) - h = np.int16(np.round(h*resize)) - print(f"new:{w},{h}") - image_resized = cv2.resize(im, dsize=(w, h), interpolation=cv2.INTER_CUBIC) - for i in range(0,np.int16(size/2)): - for j in range(0,w,np.int16(size/2)): - patch = image_resized[i:i+size, j:j+size] - if patch.shape[0] == patch.shape[1] and patch.shape[0] == size: - k += 1 - imsave(os.path.join(outpath, f"{k}_{f}"), patch) \ No newline at end of file diff --git a/plugins/.ipynb_checkpoints/bioimageio-colab-client.imjoy-checkpoint.html b/plugins/.ipynb_checkpoints/bioimageio-colab-client.imjoy-checkpoint.html deleted file mode 100644 index e8ca2e9..0000000 --- a/plugins/.ipynb_checkpoints/bioimageio-colab-client.imjoy-checkpoint.html +++ /dev/null @@ -1,90 +0,0 @@ - -[TODO: write documentation for this plugin.] - - - -{ - "name": "BioImage.IO Colab Client", - "type": "web-worker", - "tags": [], - "ui": "", - "version": "0.1.0", - "cover": "", - "description": "[TODO: describe this plugin with one sentence.]", - "icon": "extension", - "inputs": null, - "outputs": null, - "api_version": "0.1.8", - "env": "", - "permissions": [], - "requirements": [], - "dependencies": [] -} - - -