Spaces:
Runtime error
Runtime error
Commit
ยท
20d1a10
1
Parent(s):
aac52ac
test
Browse files- app.py +64 -38
- requirements.txt +0 -1
app.py
CHANGED
|
@@ -1,45 +1,71 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import torch
|
| 3 |
-
import torchvision.transforms as T
|
| 4 |
-
from PIL import Image
|
| 5 |
-
|
| 6 |
-
# Assuming the necessary packages (featup, clip, etc.) are installed and accessible
|
| 7 |
-
from featup.util import norm, unnorm
|
| 8 |
-
from featup.plotting import plot_feats
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Setup - ensure the repository content is accessible in the environment
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
input_size = 224
|
| 22 |
-
transform = T.Compose([
|
| 23 |
-
T.Resize(input_size),
|
| 24 |
-
T.CenterCrop((input_size, input_size)),
|
| 25 |
-
T.ToTensor(),
|
| 26 |
-
norm
|
| 27 |
-
])
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Model selection
|
| 32 |
-
model_option = st.selectbox(
|
| 33 |
-
'Choose a model for feature upsampling',
|
| 34 |
-
('dino16', 'dinov2', 'clip', 'resnet50')
|
| 35 |
-
)
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
upsampler = torch.hub.load("mhamilton723/FeatUp", model_option).cuda()
|
| 40 |
-
hr_feats = upsampler(image_tensor)
|
| 41 |
-
lr_feats = upsampler.model(image_tensor)
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# import streamlit as st
|
| 2 |
+
# import torch
|
| 3 |
+
# import torchvision.transforms as T
|
| 4 |
+
# from PIL import Image
|
| 5 |
+
#
|
| 6 |
+
# # Assuming the necessary packages (featup, clip, etc.) are installed and accessible
|
| 7 |
+
# from featup.util import norm, unnorm
|
| 8 |
+
# from featup.plotting import plot_feats
|
| 9 |
+
#
|
| 10 |
+
# # Setup - ensure the repository content is accessible in the environment
|
| 11 |
+
#
|
| 12 |
+
# # Streamlit UI
|
| 13 |
+
# st.title("Feature Upsampling Demo")
|
| 14 |
+
#
|
| 15 |
+
# # File uploader
|
| 16 |
+
# uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
| 17 |
+
# if uploaded_file is not None:
|
| 18 |
+
# image = Image.open(uploaded_file).convert("RGB")
|
| 19 |
+
#
|
| 20 |
+
# # Image preprocessing
|
| 21 |
+
# input_size = 224
|
| 22 |
+
# transform = T.Compose([
|
| 23 |
+
# T.Resize(input_size),
|
| 24 |
+
# T.CenterCrop((input_size, input_size)),
|
| 25 |
+
# T.ToTensor(),
|
| 26 |
+
# norm
|
| 27 |
+
# ])
|
| 28 |
+
#
|
| 29 |
+
# image_tensor = transform(image).unsqueeze(0) # Assuming CUDA is available, .cuda()
|
| 30 |
+
#
|
| 31 |
+
# # Model selection
|
| 32 |
+
# model_option = st.selectbox(
|
| 33 |
+
# 'Choose a model for feature upsampling',
|
| 34 |
+
# ('dino16', 'dinov2', 'clip', 'resnet50')
|
| 35 |
+
# )
|
| 36 |
+
#
|
| 37 |
+
# if st.button('Upsample Features'):
|
| 38 |
+
# # Load the selected model
|
| 39 |
+
# upsampler = torch.hub.load("mhamilton723/FeatUp", model_option).cuda()
|
| 40 |
+
# hr_feats = upsampler(image_tensor)
|
| 41 |
+
# lr_feats = upsampler.model(image_tensor)
|
| 42 |
+
#
|
| 43 |
+
# # Plotting - adjust the plot_feats function or find an alternative to display images in Streamlit
|
| 44 |
+
# # This step will likely need customization to display within Streamlit's interface
|
| 45 |
+
# plot_feats(unnorm(image_tensor)[0], lr_feats[0], hr_feats[0])
|
| 46 |
|
|
|
|
| 47 |
|
| 48 |
+
import streamlit as st
|
| 49 |
+
import torch
|
| 50 |
|
| 51 |
+
def check_gpu_status():
|
| 52 |
+
# Check if CUDA (GPU support) is available in PyTorch
|
| 53 |
+
cuda_available = torch.cuda.is_available()
|
| 54 |
+
gpu_count = torch.cuda.device_count()
|
| 55 |
+
gpu_name = torch.cuda.get_device_name(0) if cuda_available else "Not Available"
|
| 56 |
|
| 57 |
+
return cuda_available, gpu_count, gpu_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
# Streamlit page configuration
|
| 60 |
+
st.title("PyTorch GPU Availability Test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
# Checking the GPU status
|
| 63 |
+
cuda_available, gpu_count, gpu_name = check_gpu_status()
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
# Displaying the results
|
| 66 |
+
if cuda_available:
|
| 67 |
+
st.success(f"GPU is available! ๐")
|
| 68 |
+
st.info(f"Number of GPUs available: {gpu_count}")
|
| 69 |
+
st.info(f"GPU Name: {gpu_name}")
|
| 70 |
+
else:
|
| 71 |
+
st.error("GPU is not available. ๐ข")
|
requirements.txt
CHANGED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
git+https://github.com/mhamilton723/FeatUp
|
|
|
|
|
|