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

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": "",
<docs>
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "ImageViewerServices",
"type": "web-worker",
"tags": [],
"ui": "",
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "React UI Plugin",
"type": "window",
"tags": [],
"ui": "",
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "stlite Demo",
"type": "window",
"tags": [],
"ui": "",
import asyncio
import threading
from concurrent.futures import ThreadPoolExecutor
from imjoy_rpc.hypha import connect_to_server
import time
class BackgroundServer:
def __init__(self, server_url):
self.loop = None