Skip to content

Instantly share code, notes, and snippets.

View oeway's full-sized avatar

Wei Ouyang oeway

  • Science For Life Laboratory
  • Stockholm
View GitHub Profile
@oeway
oeway / openai_server.py
Created September 9, 2024 08:05
Create OpenAI Chat Server via Hypha
import asyncio
import random
from hypha_rpc.utils.serve import create_openai_chat_server
async def text_generator(request: dict):
max_tokens = request.get("max_tokens", 50)
words = [
"hello",
"world",
@oeway
oeway / README.md
Created June 30, 2024 21:25
Python script for setting up a WebSocket proxy in Google Colab to communicate between the embedded web page with a WebSocket server.

Description for colab_websocket.js

Title: colab_websocket.js

Description: This JavaScript file implements a WebSocket client for Google Colab that facilitates communication between the Colab notebook and a WebSocket server. It includes buffer handling for binary data and a simple debug console for sending and receiving messages.

Description for colab_websocket_proxy.py

Title: colab_websocket_proxy.py

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oeway
oeway / imageUtils.py
Last active May 8, 2024 14:21
Improved image transform functions for dense predictions (for pytorch, keras etc.)
import numpy as np
import scipy
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.interpolation import map_coordinates
import collections
from PIL import Image
import numbers
__author__ = "Wei OUYANG"
import sys, os
import imagej
import scyjava as sj
import argparse
import asyncio
import traceback
import numpy as np
import xarray as xr
from jpype import JOverride, JImplements
from imjoy_rpc.hypha import connect_to_server
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "CodeInterpreter",
"type": "window",
"tags": [],
"ui": "",
@oeway
oeway / proxy_server.py
Last active January 21, 2024 12:12 — forked from barrachri/proxy_server.py
Proxy Server with aiohttp
import logging
import sys
from urllib.parse import urljoin
import asyncio
import aiohttp
from aiohttp import web
TARGET_SERVER_BASE_URL = 'http://127.0.0.1:8888'
<docs>
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "ImageViewerServices",
"type": "web-worker",
"tags": [],
"ui": "",
@oeway
oeway / VizarrReferenceStore-Zenodo.imjoy.html
Last active October 19, 2023 03:17
Upload large files to zenodo and serve it as a zarr store (not working yet because zenodo doesn't support range header)
<docs>
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "VizarrReferenceStore",
"type": "web-worker",
"tags": [],
"ui": "",
@oeway
oeway / README.md
Last active October 11, 2023 16:43

SAM for the BioEngine

Inference

Here are some files for converting SAM models to make it available in the BioEngine (local deployment: https://github.com/oeway/bioengine/).

The tree strcture for the model repository is like this:

├── sam-backbone
│ ├── 1