Spaces:
Runtime error
Runtime error
Commit
•
8249557
1
Parent(s):
8d28891
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,12 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from
|
4 |
-
import
|
5 |
-
import
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
#os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth")
|
11 |
-
|
12 |
-
#model = torch.hub.load('pytorch/vision:v0.9.0', 'mobilenet_v2', pretrained=False)
|
13 |
-
#checkpoint = 'https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/model_weights_mobilenet_v2_valp1trainp2.pth'
|
14 |
-
#model.load_state_dict(torch.hub.load_state_dict_from_url(checkpoint, progress=False))
|
15 |
-
model = models.vgg16()
|
16 |
-
num_ftrs = model.classifier[6].in_features
|
17 |
-
model.classifier[6] = nn.Linear(num_ftrs, 6)
|
18 |
-
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
|
19 |
-
#model = model.to(device)
|
20 |
-
model.load_state_dict(torch.load('VGG16_weights_May28.pth',map_location=device))
|
21 |
-
|
22 |
-
#torch.hub.download_url_to_file("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
|
23 |
-
|
24 |
-
|
25 |
def inference(input_image):
|
26 |
preprocess = transforms.Compose([
|
27 |
transforms.Resize(260),
|
@@ -62,7 +47,7 @@ def inference(input_image):
|
|
62 |
result = {}
|
63 |
for i in range(top5_prob.size(0)):
|
64 |
result[categories[top5_catid[i].item()]] = top5_prob[i].item()
|
65 |
-
return result
|
66 |
|
67 |
inputs = gr.Image(type='pil')
|
68 |
outputs = gr.Label(type="confidences",num_top_classes=5)
|
|
|
1 |
+
#Imports
|
2 |
+
import tensorflow as tf
|
3 |
+
from tensorflow import keras
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import tensorflow_hub as hub
|
6 |
+
|
7 |
+
#Load Magenta Arbitrary Image Stylization network
|
8 |
+
hub_module = hub.load('https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/1')
|
9 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def inference(input_image):
|
11 |
preprocess = transforms.Compose([
|
12 |
transforms.Resize(260),
|
|
|
47 |
result = {}
|
48 |
for i in range(top5_prob.size(0)):
|
49 |
result[categories[top5_catid[i].item()]] = top5_prob[i].item()
|
50 |
+
return result"""
|
51 |
|
52 |
inputs = gr.Image(type='pil')
|
53 |
outputs = gr.Label(type="confidences",num_top_classes=5)
|