Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
(cherry picked from commit 6aea035)
  • Loading branch information
ospillinger authored and deliahu committed Nov 5, 2019
1 parent bc653d7 commit 815dfa6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions examples/pytorch/image-classifier/predictor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import requests
import torch
import torchvision
from torchvision import transforms
from PIL import Image
from io import BytesIO
from torchvision import transforms
import torchvision
import torch

model = torchvision.models.alexnet(pretrained=True)
model.eval()
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/image-classifier/sample.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"url": "https://bowwowinsurance.com.au/wp-content/uploads/2018/10/akita-700x700.jpg"
"url": "https://i.imgur.com/PzXprwl.jpg"
}
4 changes: 3 additions & 1 deletion examples/pytorch/iris-classifier/src/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import torch
from model import IrisNet

labels = ["iris-setosa", "iris-versicolor", "iris-virginica"]

model = IrisNet()

Expand All @@ -12,6 +11,9 @@ def init(model_path, metadata):
model.eval()


labels = ["iris-setosa", "iris-versicolor", "iris-virginica"]


def predict(sample, metadata):
input_tensor = torch.FloatTensor(
[
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/text-generator/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
predictor:
path: predictor.py
metadata:
num_words: 20
num_words: 50
device: cuda # use "cpu" to run on CPUs
compute:
gpu: 1
Expand Down
14 changes: 7 additions & 7 deletions examples/pytorch/text-generator/predictor.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This file includes code which was modified from https://github.com/huggingface/transformers/blob/master/examples/run_generation.py

from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np
import argparse
import logging
from tqdm import trange
import torch.nn.functional as F
import torch
import torch.nn.functional as F
from transformers import GPT2Tokenizer, GPT2LMHeadModel
from tqdm import trange


tokenizer = GPT2Tokenizer.from_pretrained("distilgpt2")
model = GPT2LMHeadModel.from_pretrained("distilgpt2")
model.eval()
tokenizer = GPT2Tokenizer.from_pretrained("distilgpt2")

# adapted from: https://github.com/huggingface/transformers/blob/master/examples/run_generation.py

def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float("Inf")):
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow/image-classifier/sample.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"url": "https://bowwowinsurance.com.au/wp-content/uploads/2018/10/akita-700x700.jpg"
"url": "https://i.imgur.com/PzXprwl.jpg"
}

0 comments on commit 815dfa6

Please sign in to comment.