1-13-am commited on
Commit
360a5c8
1 Parent(s): 08c7869

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -2,8 +2,9 @@ import gradio as gr
2
  import torchvision
3
  import torchvision.transforms as transforms
4
  import torch
 
5
 
6
- model = torch.jit.load('https://huggingface.co/spaces/1-13-am/neural-style-transfer/blob/main/neural_style_transfer.pt')
7
 
8
  def normalize():
9
  MEAN = [0.485, 0.456, 0.406]
@@ -17,13 +18,8 @@ def denormalize():
17
  MEAN = [-mean/std for mean, std in zip(MEAN, STD)]
18
  STD = [1/std for std in STD]
19
  return transforms.Normalize(mean=MEAN, std=STD)
20
- def transformer(imsize = None, cropsize = None):
21
  transformer = []
22
- if imsize:
23
- transformer.append(transforms.Resize(imsize))
24
- if cropsize:
25
- transformer.append(transforms.RandomCrop(cropsize))
26
-
27
  transformer.append(transforms.ToTensor())
28
  transformer.append(normalize())
29
  return transforms.Compose(transformer)
 
2
  import torchvision
3
  import torchvision.transforms as transforms
4
  import torch
5
+ from huggingface_hub import load_model_from_hub
6
 
7
+ model = load_model_from_hub("https://huggingface.co/spaces/1-13-am/neural-style-transfer/blob/main/neural_style_transfer.pt")
8
 
9
  def normalize():
10
  MEAN = [0.485, 0.456, 0.406]
 
18
  MEAN = [-mean/std for mean, std in zip(MEAN, STD)]
19
  STD = [1/std for std in STD]
20
  return transforms.Normalize(mean=MEAN, std=STD)
21
+ def transformer():
22
  transformer = []
 
 
 
 
 
23
  transformer.append(transforms.ToTensor())
24
  transformer.append(normalize())
25
  return transforms.Compose(transformer)