Spaces:
Runtime error
Runtime error
Upload 14 files
Browse files- .gitattributes +5 -0
- 1.jpg +0 -0
- 2.jpg +0 -0
- 20190210_171436.jpg +0 -0
- 20190211_215501.jpg +0 -0
- 20190220_220143.jpg +3 -0
- 20190223_181415.jpg +3 -0
- 20190404_193912.jpg +3 -0
- 20190413_021309.jpg +3 -0
- 20190413_115659.jpg +3 -0
- 3.jpg +0 -0
- 4.jpg +0 -0
- 5.jpg +0 -0
- app.py +50 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
20190220_220143.jpg filter=lfs diff=lfs merge=lfs -text
|
36 |
+
20190223_181415.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
20190404_193912.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
20190413_021309.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
20190413_115659.jpg filter=lfs diff=lfs merge=lfs -text
|
1.jpg
ADDED
![]() |
2.jpg
ADDED
![]() |
20190210_171436.jpg
ADDED
![]() |
20190211_215501.jpg
ADDED
![]() |
20190220_220143.jpg
ADDED
![]() |
Git LFS Details
|
20190223_181415.jpg
ADDED
![]() |
Git LFS Details
|
20190404_193912.jpg
ADDED
![]() |
Git LFS Details
|
20190413_021309.jpg
ADDED
![]() |
Git LFS Details
|
20190413_115659.jpg
ADDED
![]() |
Git LFS Details
|
3.jpg
ADDED
![]() |
4.jpg
ADDED
![]() |
5.jpg
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from torchvision import transforms
|
6 |
+
|
7 |
+
import torch
|
8 |
+
model = torch.hub.load('pytorch/vision:v0.10.0', 'wide_resnet50_2', pretrained=True)
|
9 |
+
model = torch.hub.load('pytorch/vision:v0.10.0', 'wide_resnet101_2', pretrained=True)
|
10 |
+
model.eval()
|
11 |
+
os.system("wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt")
|
12 |
+
torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
|
13 |
+
|
14 |
+
def inference(input_image):
|
15 |
+
preprocess = transforms.Compose([
|
16 |
+
transforms.Resize(256),
|
17 |
+
transforms.CenterCrop(224),
|
18 |
+
transforms.ToTensor(),
|
19 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
20 |
+
])
|
21 |
+
input_tensor = preprocess(input_image)
|
22 |
+
input_batch = input_tensor.unsqueeze(0) # create a mini-batch as expected by the model
|
23 |
+
if torch.cuda.is_available():
|
24 |
+
input_batch = input_batch.to('cuda')
|
25 |
+
model.to('cuda')
|
26 |
+
with torch.no_grad():
|
27 |
+
output = model(input_batch)
|
28 |
+
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
29 |
+
with open("imagenet_classes.txt", "r") as f:
|
30 |
+
categories = [s.strip() for s in f.readlines()]
|
31 |
+
top5_prob, top5_catid = torch.topk(probabilities, 5)
|
32 |
+
result = {}
|
33 |
+
for i in range(top5_prob.size(0)):
|
34 |
+
result[categories[top5_catid[i]]] = top5_prob[i].item()
|
35 |
+
return result
|
36 |
+
|
37 |
+
inputs = gr.inputs.Image(type='pil')
|
38 |
+
outputs = gr.outputs.Label(type="confidences",num_top_classes=5)
|
39 |
+
|
40 |
+
title = "WRN - Wide Residual Networks"
|
41 |
+
description = "ResNet blocks based architecture where depth is decreased and width of residual networks is increased."
|
42 |
+
article = "<p style='text-align: center'><a href='https://paperswithcode.com/paper/wide-residual-networks'>Wide Residual Networks on Papers With Code</a></p>"
|
43 |
+
examples = [
|
44 |
+
['1.jpg'],
|
45 |
+
['2.jpg'],
|
46 |
+
['3.jpg'],
|
47 |
+
['4.jpg'],
|
48 |
+
['5.jpg'],
|
49 |
+
]
|
50 |
+
gr.Interface(inference, inputs, outputs, title=title, description=description, article=article, examples=examples, analytics_enabled=False).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
Pillow
|
2 |
+
torch
|
3 |
+
torchvision
|