Spaces:
Runtime error
Runtime error
artyaltanzaya
commited on
Commit
·
7219aaf
1
Parent(s):
fc8e9c1
app
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import subprocess
|
|
5 |
subprocess.run(["bash", "setup.sh"])
|
6 |
from segment_anything import SamPredictor, sam_model_registry
|
7 |
from diffusers import StableDiffusionInpaintPipeline
|
8 |
-
from groundingdino.util.inference import load_model, load_image, predict, annotate
|
9 |
from GroundingDINO.groundingdino.util import box_ops
|
10 |
from PIL import Image
|
11 |
import torch
|
@@ -15,7 +15,7 @@ import os
|
|
15 |
device = 'cuda'
|
16 |
# ----SAM
|
17 |
|
18 |
-
|
19 |
# If weights are not present, download them.
|
20 |
if not os.path.exists("./weights/sam_vit_h_4b8939.pth"):
|
21 |
print("Downloading model weights...")
|
@@ -25,11 +25,11 @@ if not os.path.exists("./weights/groundingdino_swint_ogc.pth"):
|
|
25 |
wget.download("https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth", out="./weights/groundingdino_swint_ogc.pth")
|
26 |
|
27 |
model_type = "vit_h"
|
28 |
-
predictor = SamPredictor(sam_model_registry[model_type](checkpoint="./
|
29 |
# ------Stable Diffusion
|
30 |
pipe = StableDiffusionInpaintPipeline.from_pretrained("stabilityai/stable-diffusion-2-inpainting", torch_dtype=torch.float16,).to(device)
|
31 |
# ----Grounding DINO
|
32 |
-
groundingdino_model = load_model("./
|
33 |
|
34 |
BOX_TRESHOLD = 0.3
|
35 |
TEXT_TRESHOLD = 0.25
|
|
|
5 |
subprocess.run(["bash", "setup.sh"])
|
6 |
from segment_anything import SamPredictor, sam_model_registry
|
7 |
from diffusers import StableDiffusionInpaintPipeline
|
8 |
+
from GroundingDINO.groundingdino.util.inference import load_model, load_image, predict, annotate
|
9 |
from GroundingDINO.groundingdino.util import box_ops
|
10 |
from PIL import Image
|
11 |
import torch
|
|
|
15 |
device = 'cuda'
|
16 |
# ----SAM
|
17 |
|
18 |
+
print("path", os.getcwd())
|
19 |
# If weights are not present, download them.
|
20 |
if not os.path.exists("./weights/sam_vit_h_4b8939.pth"):
|
21 |
print("Downloading model weights...")
|
|
|
25 |
wget.download("https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth", out="./weights/groundingdino_swint_ogc.pth")
|
26 |
|
27 |
model_type = "vit_h"
|
28 |
+
predictor = SamPredictor(sam_model_registry[model_type](checkpoint="./weights/sam_vit_h_4b8939.pth").to(device="cuda"))
|
29 |
# ------Stable Diffusion
|
30 |
pipe = StableDiffusionInpaintPipeline.from_pretrained("stabilityai/stable-diffusion-2-inpainting", torch_dtype=torch.float16,).to(device)
|
31 |
# ----Grounding DINO
|
32 |
+
groundingdino_model = load_model("./groundingdino/config/GroundingDINO_SwinT_OGC.py", "./weights/groundingdino_swint_ogc.pth")
|
33 |
|
34 |
BOX_TRESHOLD = 0.3
|
35 |
TEXT_TRESHOLD = 0.25
|
setup.sh
CHANGED
@@ -21,6 +21,5 @@ wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alp
|
|
21 |
|
22 |
# Change directory back to the project root
|
23 |
cd ..
|
24 |
-
cd GroundingDINO
|
25 |
pwd
|
26 |
ls
|
|
|
21 |
|
22 |
# Change directory back to the project root
|
23 |
cd ..
|
|
|
24 |
pwd
|
25 |
ls
|