Spaces:
Running on Zero
Running on Zero
[Admin maintenance] Migrate to ZeroGPU
#2
by multimodalart HF Staff - opened
- README.md +2 -1
- app.py +14 -3
- depth/models_depth/model.py +2 -2
- depth/models_depth/model_vpd.py +2 -2
- depth/utils.py +1 -1
- requirements.txt +17 -27
- stable-diffusion/ldm/models/diffusion/ddpm.py +1 -1
README.md
CHANGED
|
@@ -4,7 +4,8 @@ emoji: 📚
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.49.1
|
| 8 |
+
python_version: '3.10'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
app.py
CHANGED
|
@@ -1,6 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'depth')))
|
| 5 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'refer')))
|
| 6 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'stable-diffusion')))
|
|
@@ -49,7 +58,8 @@ def create_depth_demo(model, device):
|
|
| 49 |
depth_image = gr.Image(label="Depth Map", elem_id='img-display-output')
|
| 50 |
raw_file = gr.File(label="16-bit raw depth, multiplier:256")
|
| 51 |
submit = gr.Button("Submit")
|
| 52 |
-
|
|
|
|
| 53 |
def on_submit(image):
|
| 54 |
transform = transforms.ToTensor()
|
| 55 |
image = transform(image).unsqueeze(0).to(device)
|
|
@@ -85,7 +95,8 @@ def create_refseg_demo(model, tokenizer, device):
|
|
| 85 |
refseg_image = gr.Image(label="Output Mask", elem_id='img-display-output')
|
| 86 |
input_text = gr.Textbox(label='Prompt', placeholder='Please upload your image first', lines=2)
|
| 87 |
submit = gr.Button("Submit")
|
| 88 |
-
|
|
|
|
| 89 |
def on_submit(image, text):
|
| 90 |
# Convert PIL -> np array
|
| 91 |
transform = transforms.ToTensor()
|
|
@@ -163,7 +174,7 @@ def main():
|
|
| 163 |
gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/MykolaL/evp?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
|
| 164 |
<p><img src="https://visitor-badge.glitch.me/badge?page_id=MykolaL/evp" alt="visitors"></p></center>''')
|
| 165 |
|
| 166 |
-
demo.queue().launch(
|
| 167 |
|
| 168 |
|
| 169 |
if __name__ == '__main__':
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
| 4 |
+
import spaces
|
| 5 |
+
|
| 6 |
+
# Re-export init helpers that mmcv 2.x moved to mmengine.model, so the remote
|
| 7 |
+
# trust_remote_code modules (MykolaL/evp_depth, MykolaL/evp_refer) keep working.
|
| 8 |
+
import mmcv.cnn as _mmcv_cnn
|
| 9 |
+
from mmengine.model import constant_init as _constant_init, normal_init as _normal_init
|
| 10 |
+
_mmcv_cnn.constant_init = _constant_init
|
| 11 |
+
_mmcv_cnn.normal_init = _normal_init
|
| 12 |
+
|
| 13 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'depth')))
|
| 14 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'refer')))
|
| 15 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'stable-diffusion')))
|
|
|
|
| 58 |
depth_image = gr.Image(label="Depth Map", elem_id='img-display-output')
|
| 59 |
raw_file = gr.File(label="16-bit raw depth, multiplier:256")
|
| 60 |
submit = gr.Button("Submit")
|
| 61 |
+
|
| 62 |
+
@spaces.GPU
|
| 63 |
def on_submit(image):
|
| 64 |
transform = transforms.ToTensor()
|
| 65 |
image = transform(image).unsqueeze(0).to(device)
|
|
|
|
| 95 |
refseg_image = gr.Image(label="Output Mask", elem_id='img-display-output')
|
| 96 |
input_text = gr.Textbox(label='Prompt', placeholder='Please upload your image first', lines=2)
|
| 97 |
submit = gr.Button("Submit")
|
| 98 |
+
|
| 99 |
+
@spaces.GPU
|
| 100 |
def on_submit(image, text):
|
| 101 |
# Convert PIL -> np array
|
| 102 |
transform = transforms.ToTensor()
|
|
|
|
| 174 |
gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/MykolaL/evp?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
|
| 175 |
<p><img src="https://visitor-badge.glitch.me/badge?page_id=MykolaL/evp" alt="visitors"></p></center>''')
|
| 176 |
|
| 177 |
+
demo.queue().launch()
|
| 178 |
|
| 179 |
|
| 180 |
if __name__ == '__main__':
|
depth/models_depth/model.py
CHANGED
|
@@ -9,8 +9,8 @@
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
from timm.models.layers import trunc_normal_, DropPath
|
| 12 |
-
from mmcv.cnn import
|
| 13 |
-
|
| 14 |
from omegaconf import OmegaConf
|
| 15 |
from ldm.util import instantiate_from_config
|
| 16 |
import torch.nn.functional as F
|
|
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
from timm.models.layers import trunc_normal_, DropPath
|
| 12 |
+
from mmcv.cnn import build_conv_layer, build_norm_layer, build_upsample_layer
|
| 13 |
+
from mmengine.model import constant_init, normal_init
|
| 14 |
from omegaconf import OmegaConf
|
| 15 |
from ldm.util import instantiate_from_config
|
| 16 |
import torch.nn.functional as F
|
depth/models_depth/model_vpd.py
CHANGED
|
@@ -9,8 +9,8 @@
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
from timm.models.layers import trunc_normal_, DropPath
|
| 12 |
-
from mmcv.cnn import
|
| 13 |
-
|
| 14 |
from omegaconf import OmegaConf
|
| 15 |
from ldm.util import instantiate_from_config
|
| 16 |
import torch.nn.functional as F
|
|
|
|
| 9 |
import torch
|
| 10 |
import torch.nn as nn
|
| 11 |
from timm.models.layers import trunc_normal_, DropPath
|
| 12 |
+
from mmcv.cnn import build_conv_layer, build_norm_layer, build_upsample_layer
|
| 13 |
+
from mmengine.model import constant_init, normal_init
|
| 14 |
from omegaconf import OmegaConf
|
| 15 |
from ldm.util import instantiate_from_config
|
| 16 |
import torch.nn.functional as F
|
depth/utils.py
CHANGED
|
@@ -18,7 +18,7 @@ from pathlib import Path
|
|
| 18 |
|
| 19 |
import torch
|
| 20 |
import torch.distributed as dist
|
| 21 |
-
from
|
| 22 |
|
| 23 |
from tensorboardX import SummaryWriter
|
| 24 |
|
|
|
|
| 18 |
|
| 19 |
import torch
|
| 20 |
import torch.distributed as dist
|
| 21 |
+
from math import inf
|
| 22 |
|
| 23 |
from tensorboardX import SummaryWriter
|
| 24 |
|
requirements.txt
CHANGED
|
@@ -1,30 +1,20 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
bitsandbytes==0.37.0
|
| 6 |
-
transformers==4.35.2
|
| 7 |
-
diffusers
|
| 8 |
-
invisible-watermark
|
| 9 |
accelerate
|
| 10 |
-
albumentations
|
| 11 |
-
opencv-python
|
| 12 |
-
|
| 13 |
-
imageio
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
omegaconf==2.1.1
|
| 17 |
-
test-tube>=0.7.5
|
| 18 |
-
streamlit>=0.73.1
|
| 19 |
einops==0.7.0
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
pydantic==2.8.2
|
| 27 |
-
pydantic-core==2.20.1
|
| 28 |
-
fastapi==0.112.4
|
| 29 |
-e git+https://github.com/openai/CLIP.git@main#egg=clip
|
| 30 |
-
-e git+https://github.com/CompVis/taming-transformers.git#egg=taming-transformers
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
torchvision
|
| 3 |
+
transformers==4.35.2
|
| 4 |
+
diffusers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
accelerate
|
| 6 |
+
albumentations
|
| 7 |
+
opencv-python
|
| 8 |
+
imageio
|
| 9 |
+
imageio-ffmpeg
|
| 10 |
+
pytorch-lightning
|
| 11 |
+
omegaconf
|
|
|
|
|
|
|
|
|
|
| 12 |
einops==0.7.0
|
| 13 |
+
torchmetrics
|
| 14 |
+
kornia
|
| 15 |
+
mmcv-lite
|
| 16 |
+
mmengine
|
| 17 |
+
tensorboardX
|
| 18 |
+
timm
|
|
|
|
|
|
|
|
|
|
| 19 |
-e git+https://github.com/openai/CLIP.git@main#egg=clip
|
| 20 |
+
-e git+https://github.com/CompVis/taming-transformers.git#egg=taming-transformers
|
stable-diffusion/ldm/models/diffusion/ddpm.py
CHANGED
|
@@ -16,7 +16,7 @@ from contextlib import contextmanager
|
|
| 16 |
from functools import partial
|
| 17 |
from tqdm import tqdm
|
| 18 |
from torchvision.utils import make_grid
|
| 19 |
-
from pytorch_lightning.utilities
|
| 20 |
|
| 21 |
from ldm.util import log_txt_as_img, exists, default, ismap, isimage, mean_flat, count_params, instantiate_from_config
|
| 22 |
from ldm.modules.ema import LitEma
|
|
|
|
| 16 |
from functools import partial
|
| 17 |
from tqdm import tqdm
|
| 18 |
from torchvision.utils import make_grid
|
| 19 |
+
from pytorch_lightning.utilities import rank_zero_only
|
| 20 |
|
| 21 |
from ldm.util import log_txt_as_img, exists, default, ismap, isimage, mean_flat, count_params, instantiate_from_config
|
| 22 |
from ldm.modules.ema import LitEma
|