Skip to content

Instantly share code, notes, and snippets.

View geoffreyangus's full-sized avatar

Geoffrey Angus geoffreyangus

View GitHub Profile
@geoffreyangus
geoffreyangus / method_3.py
Created November 21, 2022 21:17
Method 3: Running Inference on Each Module Separately
import json
from pprint import pprint
import pandas as pd
import torch
from ludwig.utils.inference_utils import to_inference_module_input_from_dataframe
preprocessor = torch.jit.load(
f"{EXPERIMENT_DIRECTORY}/torchscript/inference_preprocessor.pt")
@geoffreyangus
geoffreyangus / method_2.py
Created November 21, 2022 21:17
Method 2: Convert `InferenceModule` Into a Single TorchScript Module
import json
from pprint import pprint
import pandas as pd
import torch
from ludwig.models.inference import InferenceModule
from ludwig.utils.inference_utils import to_inference_module_input_from_dataframe
inference_module = InferenceModule.from_directory(
@geoffreyangus
geoffreyangus / method_1.py
Last active November 21, 2022 21:16
Method 1: Using the `InferenceModule` Class
from pprint import pprint
import pandas as pd
from ludwig.models.inference import InferenceModule
inference_module = InferenceModule.from_directory(
f"{EXPERIMENT_DIRECTORY}/torchscript")
input_df = pd.read_parquet(f"{DATA_DIRECTORY}/twitter_bots.parquet")
input_sample_df = input_df.head(2)
@geoffreyangus
geoffreyangus / twitter_bots_config.yaml
Last active November 21, 2022 21:15
Step 0: Twitter Bots Ludwig config
input_features:
- name: description
type: text
column: description
- name: default_profile
type: binary
column: default_profile
- name: default_profile_image
type: binary
column: default_profile_image
@geoffreyangus
geoffreyangus / issue2292_mnist.ipynb
Last active November 8, 2022 19:29
Shows MNIST download, training, and TorchScript export, as well as errors from ONNX export.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@geoffreyangus
geoffreyangus / inference_module_example.ipynb
Created July 19, 2022 23:42
This Gist demonstrates how to perform inference using a Torchscripted LudwigModel.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@geoffreyangus
geoffreyangus / cloudSettings
Last active October 27, 2020 17:48
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-10-27T17:48:37.284Z","extensionVersion":"v3.4.3"}