breynolds1247 commited on
Commit
8249557
1 Parent(s): 8d28891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -25
app.py CHANGED
@@ -1,27 +1,12 @@
1
- import torch
2
- from PIL import Image
3
- from torchvision import datasets, models, transforms
4
- import gradio as gr
5
- import os
6
- import torch.nn as nn
7
-
8
-
9
- os.system("wget https://github.com/liuxiaoyuyuyu/vanGogh-and-Other-Artist/blob/main/artist_classes.txt")
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)