Skip to content

Commit

Permalink
updated python deps
Browse files Browse the repository at this point in the history
  • Loading branch information
edavidaja committed Mar 22, 2023
1 parent 759c7ad commit a200958
Show file tree
Hide file tree
Showing 9 changed files with 1,137 additions and 584 deletions.
2 changes: 1 addition & 1 deletion reticulated-image-classifier/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ server <- function(input, output, session) {
} else {
return(list(src = new_path, style = htmltools::css(width = "100%")))
}
})
}, deleteFile = FALSE)

# default images
observeEvent(input$oil_platform, image_path("./img/oil_platform.jpg"))
Expand Down
31 changes: 15 additions & 16 deletions reticulated-image-classifier/image-classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
from torch.autograd import Variable

# Set PyTorch model directory
os.environ["TORCH_MODEL_ZOO"] = "./model"
os.environ["TORCH_HOME"] = "./model"

squeeze = models.squeezenet1_1(pretrained=True)
squeeze.eval()

normalize = transforms.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])

preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
normalize
])
preprocess = transforms.Compose(
[
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
normalize,
]
)

with open('labels.json') as f:
with open("labels.json") as f:
labels_data = json.load(f)

labels = {int(key):value for (key, value) in labels_data.items()}
labels = {int(key): value for (key, value) in labels_data.items()}


def classify_image_pytorch(image_path):

Expand All @@ -41,7 +41,6 @@ def classify_image_pytorch(image_path):
for prediction in top_k:
description = labels[prediction]
score = fc_out.data.numpy()[0][prediction]
results.append(('%s (score = %.5f)' % (description, score)))

return(results)
results.append(("%s (score = %.5f)" % (description, score)))

return results
801 changes: 376 additions & 425 deletions reticulated-image-classifier/manifest.json

Large diffs are not rendered by default.

Binary file not shown.
Loading

0 comments on commit a200958

Please sign in to comment.