Wazzzabeee commited on
Commit
1348930
1 Parent(s): abe6b41

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +17 -2
utils.py CHANGED
@@ -1,10 +1,13 @@
1
- import requests
2
  import numpy as np
3
- from models.deep_colorization.colorizers import postprocess_tens, preprocess_img, load_img
 
4
  from PIL import Image
5
 
 
 
6
 
7
  # Define a function that we can use to load lottie files from a link.
 
8
  def load_lottieurl(url: str):
9
  r = requests.get(url)
10
  if r.status_code != 200:
@@ -12,6 +15,18 @@ def load_lottieurl(url: str):
12
  return r.json()
13
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  def format_time(seconds: float) -> str:
16
  """Formats time in seconds to a human readable format"""
17
  if seconds < 60:
 
 
1
  import numpy as np
2
+ import requests
3
+ import streamlit as st
4
  from PIL import Image
5
 
6
+ from models.deep_colorization.colorizers import postprocess_tens, preprocess_img, load_img, eccv16, siggraph17
7
+
8
 
9
  # Define a function that we can use to load lottie files from a link.
10
+ @st.cache_data()
11
  def load_lottieurl(url: str):
12
  r = requests.get(url)
13
  if r.status_code != 200:
 
15
  return r.json()
16
 
17
 
18
+ @st.cache_resource()
19
+ def change_model(current_model, model):
20
+ if current_model != model:
21
+ if model == "ECCV16":
22
+ loaded_model = eccv16(pretrained=True).eval()
23
+ elif model == "SIGGRAPH17":
24
+ loaded_model = siggraph17(pretrained=True).eval()
25
+ return loaded_model
26
+ else:
27
+ raise Exception("Model is the same as the current one.")
28
+
29
+
30
  def format_time(seconds: float) -> str:
31
  """Formats time in seconds to a human readable format"""
32
  if seconds < 60: