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

Add ability to create Extractors 100% in the GUI #708

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KastanDay
Copy link
Contributor

@KastanDay KastanDay commented Sep 6, 2023

These are living notes, drawing from inspiration

GUI Extractor Requirements:

  1. Launch-able in GUI.

    • Implementation details
      • CPU-only for now
      • Run on your Clowder instance
      • Unsafe code is okay, just have a big red warning.
  2. Support inference Endpoints, can hit them with super simple curl.

curl -X POST \
    -H "Content-Type: application/json" \
    -d '{"prompt": "Software developers start with a Hello, [MASK]! script."}' \
    http://localhost:8000/

# result:
# {
#     "outputs": {
#         "score": 0.8281897306442261,
#         "sequence": "software developers start with a hello, world! script.",
#         "token": 2088,
#         "token_str": "world"
#     }
# }
  1. Can connect via PyClowder SDK
# from Banana.dev as inspiration, but PyClowder already does this.
from banana_dev import Client

# Create a reference to your model on Banana
my_model = Client(
    api_key="YOUR_API_KEY", # Found in dashboard
    model_key="YOUR_MODEL_KEY", # Found in model view in dashboard
    url="http://localhost:8000",
)

# Specify the model's input JSON
inputs = {
    "prompt": "Software developers start with a Hello, [MASK]! script",
}

# Call your model's inference endpoint
result, meta = my_model.call("/", inputs)
print(result)

# result:
# {
#     "outputs": {
#         "score": 0.8281897306442261,
#         "sequence": "software developers start with a hello, world! script.",
#         "token": 2088,
#         "token_str": "world"
#     }
# }
  1. Custom preprocessing setup() and predict() functions.
    1. Enter code via the GUI, 100% GUI.
# https://github.com/replicate/cog
from cog import BasePredictor, Input, Path
import torch

class Predictor(BasePredictor):
    def setup(self):
        """Load the model into memory to make running multiple predictions efficient"""
        self.model = torch.load("./weights.pth")

    # The arguments and types the model takes as input
    def predict(self,
          image: Path = Input(description="Grayscale input image")
    ) -> Path:
        """Run a single prediction on the model"""
        processed_image = preprocess(image)
        output = self.model(processed_image)
        return postprocess(output)
  1. Warning & limits for Arbitrary code execution
    1. Limit outbound (network) requests from container.
    2. Copy the permissions from MacOS.
    3. Before trying to install an "arbitrary code execution" extractor you have to agree to a big flashy warning & "no guarantees" policy. Just so they understand the concern.

CleanShot 2023-09-06 at 13 47 10

TODO: Investigate Cog as a Docker wrapper to automate job launching. It's designed for exactly this problem.

@KastanDay KastanDay marked this pull request as draft September 6, 2023 20:47
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dw, I'll clean up these comments. Just keeping them for now as I do the initial implementation.

@KastanDay
Copy link
Contributor Author

KastanDay commented Sep 12, 2023

Maybe start with SegmentAnything model for Xiaoxia Liao to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant