test
Browse files
app.py
CHANGED
@@ -5,7 +5,9 @@ import glob
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import torch
|
7 |
import torchvision.transforms as T
|
|
|
8 |
import gradio as gr
|
|
|
9 |
from pytorch_lightning import seed_everything
|
10 |
import os
|
11 |
import requests
|
@@ -14,7 +16,6 @@ import spaces
|
|
14 |
|
15 |
|
16 |
def plot_feats(image, lr, hr):
|
17 |
-
from featup.util import pca, remove_axes
|
18 |
assert len(image.shape) == len(lr.shape) == len(hr.shape) == 3
|
19 |
seed_everything(0)
|
20 |
[lr_feats_pca, hr_feats_pca], _ = pca(
|
@@ -98,7 +99,8 @@ def upsample_features(image, model_option):
|
|
98 |
cuda_dirs = glob.glob('/usr/local/cuda*')
|
99 |
|
100 |
if not cuda_dirs:
|
101 |
-
raise EnvironmentError(
|
|
|
102 |
|
103 |
# Assume the highest version of CUDA is the one to use
|
104 |
cuda_dirs.sort()
|
@@ -107,15 +109,14 @@ def upsample_features(image, model_option):
|
|
107 |
# Set the CUDA_HOME environment variable
|
108 |
os.environ['CUDA_HOME'] = cuda_home
|
109 |
os.environ['PATH'] = os.environ['CUDA_HOME'] + '/bin:' + os.environ['PATH']
|
110 |
-
os.environ['LD_LIBRARY_PATH'] = os.environ['CUDA_HOME'] +
|
|
|
111 |
|
112 |
# Install the required package from GitHub
|
113 |
-
subprocess.check_call(
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
from featup.util import norm, unnorm
|
118 |
|
|
|
119 |
|
120 |
# Image preprocessing
|
121 |
input_size = 224
|
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import torch
|
7 |
import torchvision.transforms as T
|
8 |
+
from PIL import Image
|
9 |
import gradio as gr
|
10 |
+
from featup.util import norm, unnorm, pca, remove_axes
|
11 |
from pytorch_lightning import seed_everything
|
12 |
import os
|
13 |
import requests
|
|
|
16 |
|
17 |
|
18 |
def plot_feats(image, lr, hr):
|
|
|
19 |
assert len(image.shape) == len(lr.shape) == len(hr.shape) == 3
|
20 |
seed_everything(0)
|
21 |
[lr_feats_pca, hr_feats_pca], _ = pca(
|
|
|
99 |
cuda_dirs = glob.glob('/usr/local/cuda*')
|
100 |
|
101 |
if not cuda_dirs:
|
102 |
+
raise EnvironmentError(
|
103 |
+
'No CUDA installation found. Please install CUDA or set CUDA_HOME manually.')
|
104 |
|
105 |
# Assume the highest version of CUDA is the one to use
|
106 |
cuda_dirs.sort()
|
|
|
109 |
# Set the CUDA_HOME environment variable
|
110 |
os.environ['CUDA_HOME'] = cuda_home
|
111 |
os.environ['PATH'] = os.environ['CUDA_HOME'] + '/bin:' + os.environ['PATH']
|
112 |
+
os.environ['LD_LIBRARY_PATH'] = os.environ['CUDA_HOME'] + \
|
113 |
+
'/lib64:' + os.environ.get('LD_LIBRARY_PATH', '')
|
114 |
|
115 |
# Install the required package from GitHub
|
116 |
+
subprocess.check_call(
|
117 |
+
["pip", "install", "git+https://github.com/mhamilton723/FeatUp"])
|
|
|
|
|
|
|
118 |
|
119 |
+
models = {o: torch.hub.load("mhamilton723/FeatUp", o) for o in options}
|
120 |
|
121 |
# Image preprocessing
|
122 |
input_size = 224
|